awk command line: blank line record sep, new line field sep
Hi All,
I have been trying to understand from the online awk manuals how to phrase this command line, but would greatly appreciate some help please. I have a file (temp.txt) with these contents (one field per line, blank line separates records): Code:
1st record, 1st field cat Code:
awk -F=/ "/knife/ {print \$2}" RS="" "temp.txt" Also, does awk support the notion of saying "search for the value in the first field" etc? Thank you for any assistance! |
Code:
$ awk -vRS= -vFS="\n" '/knife/{print $2}' file |
Quote:
Thank you again! |
Well ghostdog74 probably has a cleverer solution but M2C:
awk -vRS= -vFS="\n" -v output="$1.*field $2$" '$0 ~ output { print $1 }' $3 and to your script you pass field number ($1), item ($2) and filename ($3) |
In a script:
Code:
awk -vRS= -vFS="\n" "{if (\\$5 == \"$1\") print \\$1}" temp.txt |
All times are GMT -5. The time now is 04:41 PM. |