Skip to content

Instantly share code, notes, and snippets.

@jasondewitt
Created September 25, 2015 22:02
Show Gist options
  • Save jasondewitt/e4906263bd013d19627a to your computer and use it in GitHub Desktop.
Save jasondewitt/e4906263bd013d19627a to your computer and use it in GitHub Desktop.
merge log files into a single file
#!/bin/sh
export MFILE=merge_file.txt
export SFILE=complete_file.txt
for file in `ls *.log`
do
cat $file >> $MFILE
done
# -k1,2 represents the fields in the file containing the timestamps
# for this example field 1 was the date and field 2 was the time
# customize accordingly
sort -k1,2 $MFILE > $SFILE
rm $MFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment