awk help

Michael Camann camann at athena.cs.uga.edu
Wed Aug 12 14:54:59 EDT 1992


> 
> Could someone with with a greater knowledge of awk than me help me out with a short script that will read two floating point numbers from two seperate files and write out a single file with four values on each line ?
> 
> 
> Thanks in advance
> 
> Tom Nelson
> C.O.E
> Fort Worth, Texas
> 

Tom--

How about simply using awk to read the numbers into two separate temporary
files, then using paste to put them together.  This will do what you seem to
be asking for if both input files have the same number of lines.

awk '{ printf ("%f\t%f\n", $1,$2) }' input_file_1 > temp_1
awk '{ printf ("%f\t%f\n", $3,$4) }' input_file_2 > temp_2
paste temp_1 temp_2 > output_file

This will create an output file containing the first two fields from
input_fiel_1 and the third and fourth fields from input_file_2 on each line,
separated by tabs.  Of course, you can edit this to reflect the proper
input fields, separators, etc.

Hope this helps....

			Mike Camann
			camann at athena.cs.uga.edu




More information about the grass-user mailing list