awk syntax to print particular record of xyz file?
Hi.
Can anyone help me with the awk syntax to print a particular record of an xyz file? Thanks. |
this sounds an awful lot like homework to me, and your question is pretty vague... what defines a "record" to you? how do yo intend to identity said record?
|
Hi,
awk '{ print $2 }' infile => prints field number 2 if a line looks like this: A B C D, then B will be printed in the previous example. If separator isn't a space/tab: awk -F: '{ print $4 }' infile => prints field number 4 if a line looks like this: V:W:X:Y:Z, then Y will be printed in the previous example. man awk for the details. Hope this helps. |
Thanks druuna.
awk -v FS="\n" was what I needed |
If you download the gawk package source you can use the "make pdf" target to produce the book: "Gawk: Effective Awk Programming".
|
All times are GMT -5. The time now is 09:40 AM. |