Merging sorted files

You can merge two or more files at the same time as they are sorted. For example:

    sort -m -o accounts +1 -2 month[1-3]

This sorts the files month1 through month3 on the information in the second field of each line of each file. The results are merged and sent to the file accounts.

Files that have already been sorted can be merged using only the -m option. For example:

   sort -m first_qtr second_qtr > halfyear

This merges the contents of files first_qtr and second_qtr and places the result in the file halfyear.

The > character is used to direct the output of the sort command into the file halfyear.


[Home] [Search] [Index] This site maintained by unixhelp@mathcs.duq.edu