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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

concatenate two files within an awk script

Status
Not open for further replies.

jarthi

Programmer
Oct 25, 2000
31
US
Hi:

This is my script so far(except the last statement):

{
res = sprintf ("%d_%d",$1,$2)
printf "test\n" > res

cat /home/testart >> res #I can't do this

}

How do I accomplish the last statement in awk? I know 'cat' cannot be used.

Thanks,
Arthi.












 
Some more info would be helpful ... what are you trying to achieve? what do the input files look like? and what output do you expect?

Post an example and we should be able to sort it :)

Greg.
 
This may do what you want- it prints out the file
you want to concatenate to, then formats and
prints field 1 and field 2 from the file that contains
the data you want to append to the first file.

awk '

FILENAME=="file1"{ print }

FILENAME=="file2"{

res = sprintf("%d_%d",$1,$2)

print res }' file1 file2 > file3


Hope this helps you!


flogrr
flogr@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top