Computing.Net > Forums > Unix > awk-merging files by field number

awk-merging files by field number

Reply to Message Icon

Original Message
Name: Fernando Cardenas
Date: October 31, 1999 at 10:29:48 Pacific
Subject: awk-merging files by field number
Comment:

Hello there,
Please help. I would like to know how to put
two different files together in one, an be able to print specific fields(ex.first field of each file separated from the other fields.)
thanks in advance for your help.


Report Offensive Message For Removal


Response Number 1
Name: Muddassir
Date: November 4, 1999 at 02:54:57 Pacific
Subject: awk-merging files by field number
Reply: (edit)

for i in `cat file1 | cut -d ' ' -f 1`
do
(( cntr=$cntr+1 ))
cat file2 | awk -v field1=$i -v recno=$cntr '
{
if ( NR==recno )
{
{ print field1 $2 };
}
}'
done >> file3


please check out for any syntex error
Space is assumed as field seperator.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: awk-merging files by field number

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software