Operating System - HP-UX
1830525 Members
2643 Online
110006 Solutions
New Discussion

3 files, line by line, side by side

 
SOLVED
Go to solution
Bill McNAMARA_1
Honored Contributor

3 files, line by line, side by side

hi,

I've 3 files

cat file1
1
2
3

cat file2
a
b
c

cat file3
hello
bonjour
gutten tag

that I need to output like this


1 a hello
2 b bonjour
3 c gutten tag


Should be easy!

Later,
Bill
It works for me (tm)
4 REPLIES 4
Robin Wakefield
Honored Contributor
Solution

Re: 3 files, line by line, side by side

Hi Bill

paste file1 file2 file3

should do the trick!

Rgds, Robin.
John Strang
Regular Advisor

Re: 3 files, line by line, side by side

Bill,

The paste command should do what you want

paste file1 file2 file3 > file4

HTH,

John
If you never make a mistake you'll never make anything.
Helen French
Honored Contributor

Re: 3 files, line by line, side by side

Hi Bill,

Try it with 'paste' command

# paste file1 file 2 ....

See man pages for more info

HTH,
Shiju
Life is a promise, fulfill it!
Aftab Sadiq
Advisor

Re: 3 files, line by line, side by side

Hi,
By default paste command append a blank line at end and use "tab" as default seperator, you can eliminate this blank line by -s option and specify seperator with -d option.
For expample pipe is seperator in following command:

paste -s -d "|" file1 file2 file3


Aftab