extracting "rest of line" in AWK
Bob McGowen Wyse Technology Training
bob at wyse.wyse.com
Thu Sep 7 07:44:25 AEST 1989
In article <4831 at portia.Stanford.EDU> karish at forel.stanford.edu (Chuck Karish) writes:
---deleted---
>>and I want to do a {print $3} to get the "This is a Graph Heading" part,
>>but this obviously dosen't work. Is there a way to do this?
>
>{for (num = 3; num <= NF; num++) {printf "%s ", $num}}
>{printf "\n"}
Or:
awk -F\" '{print $2}'
which sets the field separator to " and then prints the second field, which
is between the two quotes. If you need the quotes output then the print
could be:
print "\""$2"\""
This will guarantee that everything between the quotes will be printed,
while anything that may follow the second quote will be ignored. Also,
no assumptions are made about the number of leading fields so modification
of the data file will be less likely to require changing of the the
awk script.
Bob McGowan (standard disclaimer, these are my own ...)
Customer Education, Wyse Technology, San Jose, CA
..!uunet!wyse!bob
bob at wyse.com
More information about the Comp.unix.questions
mailing list