Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

merge three files in one

Status
Not open for further replies.

mediation

Technical User
Nov 11, 2006
17
Dears,

I have a script which generates 3 output files, each contains one column of data as below:

file 1:

ABC
ABC
ABC


file 2:

DEF
DEF
DEF


file 3:

GHI
GHI
GHI

I want to merge all these files in one file with 3 columns as below:

file 4:


ABC DEF GHI
ABC DEF GHI
ABC DEF GHI


Could you please help me in doing this issue?? taking into consideration that i'm using ksh script and i've tried to use awk functions and failed.

Thanks in advance.
 
Dears,

Thanks for the reply ..
the first one "paste" command works but the output was the last file only NOT all the three files ...
the second command "awk" doesn't work .. it generated the following error:

\awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: illegal statement near line 1
awk: illegal statement near line 1



Finally, i had noticed when i had edited the files by vi editor that each line finishes with "^M" charachter as per below ..

$vi file1
ABC^M
ABC^M
ABC^M

can someone explain what does it mean ??? and does it affect the above commands????

Many thanks for your help.
 
Seems you play with MSDos files.
You may try this:
paste file1 file2 file3 | tr -d '\r' > file4

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top