getting a field from a line in awk/sed/?
-=Runaway Daemon=-
frechett at boulder.Colorado.EDU
Thu Jan 10 19:53:34 AEST 1991
In article <5155 at idunno.Princeton.EDU> pfalstad at phoenix.Princeton.EDU (Paul John Falstad) writes:
>In article <1991Jan9.225344.19979 at informix.com> dberg at informix.com (David I. Berg) writes:
>>Use cut. The syntax is ` cut -fn -d" " ', where n is the number of the
>>field you wish to extract. -d" " specifies spaces as the delimiter between
>>fields. `man cut' will give you all the particulars.
>
>That isn't going to work for his example (output of lpq). If you do:
>
>$ cut -d' ' -f3 <<EOF
>foo bar ble boz burn
>EOF
Ah, yes, you are right, but there is a way. How about if you know that the
first column is only 12 characters wide... Something like
cut -c1-12 <<EOF
in fact works quite well. Granted, I would use awk or perl but
cut has its uses too. Of course there are those without cut but that
is their problem.
ian
--
-=Runaway Daemon=-
More information about the Comp.unix.questions
mailing list