How to get AWK to output 2 fields at once
Ronald Pikkert
ronald at atcmp.nl
Mon Oct 29 22:39:27 AEST 1990
>From article <297 at twg.bc.ca>, by bill at twg.bc.ca (Bill Irwin):
<>
<> Is there a way to get AWK to output "field_1 field_2" as the value of x,
<> so that this can be used as the search pattern for GREP, rather than
<> "field_1" "field_2" "field_1" "field_2"?
Your problem comes up AFTER awk. The for loop that you use
considers spaces to be field seperators and awk outputs spaces
on your request.
You could do this:
cat file_1 | awk '{ print $1 " " $2 }' | while read x
do
grep "$x" file_2
done
The read statement will leave the spaces in the awk output
unchanged.
-
Ronald Pikkert E-mail: ronald at atcmp.nl
@ AT Computing b.v. Tel: 080 - 566880
Toernooiveld
6525 ED Nijmegen
More information about the Comp.unix.shell
mailing list