Results 1 to 8 of 8
Hi,
I would like to add two files together {Keeping their respective ordering}..
e.g. file 'a' contains
hi
welcome to
file 'b' contains
bob
linuxforums
so that file 'c' contains
...
- 10-09-2007 #1Just Joined!
- Join Date
- Oct 2007
- Posts
- 2
Add two files {But keep their respective order}..
Hi,
I would like to add two files together {Keeping their respective ordering}..
e.g. file 'a' contains
hi
welcome to
file 'b' contains
bob
linuxforums
so that file 'c' contains
hi
bob
welcome to
linuxforums
If I use 'cat' the contents of file 'b' are appended to the bottom of file 'a'.
I also tried using $ sed a\ fileb filea > filec {But fileb was interpreted as text as opposed to the contents of fileb}
Any help would be greatly appreciated. {This is my first post
}
Thanks
Stephen.
- 10-09-2007 #2
You can do this with join, but beware the utility is a major PITA.
- 10-09-2007 #3
You can do this with:
likwid, how would you do this with join? I looked at the man page, and just don't see that happening.Code:paste -d "\n" filename1 filename2
- 10-09-2007 #4Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Why not simply with cat?
RegardsCode:cat a b > c
- 10-09-2007 #5
Because suppose you have two files. File a contains this:
and file b contains this:Code:a1 a2 a3
If you cat them you get this:Code:b1 b2 b3
and the OP wanted this:Code:a1 a2 a3 b1 b2 b3
Code:a1 b1 a2 b2 a3 b3
- 10-09-2007 #6Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Oh my, I didn't read the question carefully
, I apologize.
Regards
- 10-09-2007 #7
You're right wje- I was half thinking of paste heh.
- 10-10-2007 #8Just Joined!
- Join Date
- Oct 2007
- Posts
- 2
Thanks very much, the past cmd worked..
{Just changed the filename order - i.e paste -d "\n" filename2 filename1}


Reply With Quote