problem with spaces in quoted string arguments
- From: "rec.woodworking" <sonnichs@xxxxxxxxxxxxx>
- Date: Thu, 25 Oct 2007 18:43:04 -0700
I am passing a list of file records to awk in an attempt to extract
the 2nd field of each record. The records consist of strings seprated
by a space. Some of the strings themselves contain spaces and these
are in double quotes. For example:
10.1.1.2 "testserver" 128.8.183.2
10.1.2.2 "photon hub" 128.8.181.2
10.1.1.7 "voltserver" 128.8.187.4
I simply cat the file into gawk and I was hoping to extract the name
fields:
cat test2 | awk '{print $2}'
"testserver"
"photon
"voltserver"
As can be seen in the output, the server called "photon hub" did not
extract properly, since the space was detected in the argument to awk.
I have looked for an option to ignore spaces within double quotes and
can find none. The easy thing to do is write a quick C program to do
this, but perhaps there is a simple work around that I do not know
about.
Thanks
Fritz
.
- Follow-Ups:
- Re: problem with spaces in quoted string arguments
- From: Chris F.A. Johnson
- Re: problem with spaces in quoted string arguments
- From: Janis Papanagnou
- Re: problem with spaces in quoted string arguments
- Prev by Date: /usr/etc/dump disk-to-disk?
- Next by Date: Re: problem with spaces in quoted string arguments
- Previous by thread: /usr/etc/dump disk-to-disk?
- Next by thread: Re: problem with spaces in quoted string arguments
- Index(es):
Relevant Pages
|