Merging two log files
Posted 11-14-2011 at 04:52 AM by zhjim
Today I needed to merge two log files in cronological together. Heres my way about.
copy the two files to one host. (scp file name@server:~userhome
get the hostname infront of each line. (sed -i s/^/hostname/g first_file; ...)
cat ./first_file ./second_file | sort -k 3 > ./new_log
-k in sort stands for key. In my turn the datetime was the third field.
Improvements:
Get some color into the diffrence hostsnames.
copy the two files to one host. (scp file name@server:~userhome
get the hostname infront of each line. (sed -i s/^/hostname/g first_file; ...)
cat ./first_file ./second_file | sort -k 3 > ./new_log
-k in sort stands for key. In my turn the datetime was the third field.
Improvements:
Get some color into the diffrence hostsnames.
Total Comments 0



