Originally posted by: orphy
Any reason why you don't like cat?
some people think they are cute! Regardless of what you use, the contents of the files will have to be read to be merged somehow although, depending on how you do it, one of them might just need of seek.
Here's a quick way to do it or you can just can it all the way...
-
cat o1
file 1, line 1
file 1, line 2
file 1, line 3
-
cat o2
file 2, line 1
file 2, line 2
file 2, line 3
-
perl -pi -e 'print "add me to top of file\n" if $. == 1' o1
-
cat o1
add me to top of file
file 1, line 1
file 1, line 2
file 1, line 3
-
cat o1 o2 >> o3
-
cat o3
add me to top of file
file 1, line 1
file 1, line 2
file 1, line 3
file 2, line 1
file 2, line 2
file 2, line 3
Or if you don't care about preserving the original files, simply run the perl o1 and then cat o2 >> o1. That will save you an inode!
Orphy
#AIX-Forum