Learn something new every day
Wednesday, February 9, 2011
Solution: merge two files / append two files in Linux
Code:
cat file1 file2 .. fileN > mergedfile
Note the '>' in the command: it points that the target file follows, don't forget to put it there.
Advance:
If you accept that entries in the resulting file are sorted, you can use
uniq
to remove duplicates.
Code:
cat file1 file2 | sort | uniq > mergedfile
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment