Article 4TRSJ BASH : how to sort bunch of .log files ?

BASH : how to sort bunch of .log files ?

by
nartotik
from LinuxQuestions.org on (#4TRSJ)
hi guys.
im new to bash scripting so i need your help.
i got an assignment that im having trouble to deal with.

i got a bunch of .log files that some of them are "corrupt"
example for a "corrupt" log file:
2019-08-22T13:33:44.123456789 Hello
World
2020-01-01T11:22:33.123456789 late

i need to write a script that sort the .log files in a given path (also in the sub directories of the given path) and keep the content of the log file.

example on 3 log file:
1.log
2019-08-22T13:33:44.123456789 Hello
World
2020-01-01T11:22:33.123456789 late
2.log
2019-09-44T13:44:21.987654321 Simple line
3.log
2019-08-22T13:33:44.123456789 Hello
World 2
2020-01-01T11:22:33.123456789 late 2

the output needs to be:
""2019-08-22T13:33:44.123456789"" ""Hello""
""World""
""2019-08-22T13:33:44.123456789"" ""Hello""
""World"" ""2""
""2019-09-44T13:44:21.987654321"" ""Simple"" ""line""
""2020-01-01T11:22:33.123456789"" ""late""
""2020-01-01T11:22:33.123456789"" ""late"" ""2""
Code:my script so far:
#!/bin/bash
path=$1
if cd $path;then
output="$(find ${dir} -name "*.log" | xargs cat | tr -d '\0' | sort -n -k1,1 -k2,2 )"
echo "${output}"
(exit 0)
else
(exit 2);
fithanks in advance for all the helpers!!latest?d=yIl2AUoC8zA latest?i=0ONhJTs0UlA:IhD-BL6_GiA:F7zBnMy latest?i=0ONhJTs0UlA:IhD-BL6_GiA:V_sGLiP latest?d=qj6IDK7rITs latest?i=0ONhJTs0UlA:IhD-BL6_GiA:gIN9vFw0ONhJTs0UlA
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments