Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!caen!hellgate.utah.edu!csn!news From: frechett@boulder.Colorado.EDU (-=Runaway Daemon=-) Newsgroups: comp.unix.questions Subject: Re: getting a field from a line in awk/sed/? Message-ID: <1991Jan10.085334.19790@csn.org> Date: 10 Jan 91 08:53:34 GMT References: <1991Jan9.162817.17038@porthos.cc.bellcore.com> <1991Jan9.225344.19979@informix.com> <5155@idunno.Princeton.EDU> Sender: news@csn.org Reply-To: frechett@snoopy.Colorado.EDU (-=Runaway Daemon=-) Organization: University of Colorado, Boulder Lines: 22 Nntp-Posting-Host: snoopy.colorado.edu In article <5155@idunno.Princeton.EDU> pfalstad@phoenix.Princeton.EDU (Paul John Falstad) writes: >In article <1991Jan9.225344.19979@informix.com> dberg@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 <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 <