ast@cs.vu.nl (Andy Tanenbaum) (01/09/90)
I treid using cut yesterday to extract the third column from a crc listing like this: 65261 8510 alloc.c 09176 7432 break.c 53152 990 const.h I could not find any combination of -d and -i flags to convince it to consider a run of spaces as a separator. I eventually did it with columns, but I think it ought to work with fields as well. Does anyone (e.g., the author) know how to do this? Andy Tanenbaum (ast@cs.vu.nl)
paula@bcsaic.UUCP (Paul Allen) (01/11/90)
In article <5067@ast.cs.vu.nl> ast@cs.vu.nl (Andy Tanenbaum) writes: > >I treid using cut yesterday to extract the third column from a crc listing >like this: > >65261 8510 alloc.c >09176 7432 break.c >53152 990 const.h > >I could not find any combination of -d and -i flags to convince it to consider >a run of spaces as a separator. I eventually did it with columns, but I >think it ought to work with fields as well. Does anyone (e.g., the author) >know how to do this? My experience with cut(1) on Suns and Ultrix is that a run of delimiter characters is always a series of empty fields. I suppose you could do something like: (while read line do echo $line done) <myfile |cut -f3 -d\<space> Slow for big files, but it works. Does the System V cut(1) have an option to treat runs of delimiters as a single delimiter? Paul Allen -- ------------------------------------------------------------------------ Paul L. Allen | pallen@atc.boeing.com Boeing Advanced Technology Center | ...!uw-beaver!bcsaic!pallen
wtr@moss.ATT.COM (3673,ATTT) (01/12/90)
In article <18787@bcsaic.UUCP> paula@bcsaic.UUCP (Paul Allen) writes: >In article <5067@ast.cs.vu.nl> ast@cs.vu.nl (Andy Tanenbaum) writes: >> >>I treid using cut yesterday to extract the third column from a crc listing >>like this: >> >>65261 8510 alloc.c >>09176 7432 break.c >>53152 990 const.h >> >>I could not find any combination of -d and -i flags to convince it to consider >>a run of spaces as a separator. I eventually did it with columns, but I >>think it ought to work with fields as well. Does anyone (e.g., the author) >>know how to do this? > >My experience with cut(1) on Suns and Ultrix is that a run of delimiter >characters is always a series of empty fields. ... >Does the System V cut(1) have an >option to treat runs of delimiters as a single delimiter? >Paul Allen Nope. SysV behaves the same way. (At least our SysVr3.1 Vaxen do) A method to get around this problem is to use tr(1) to remove all double spaces: cat file | tr -s ' ' ' ' | cut -d' ' -f???? Sorry, but I don't have a minix system in front of me, and have only played with one briefly. Does minix have tr(1)? Hope this helps, -bill. -- ===================================================================== Bill Rankin email address: att!moss!wtr was: Bell Labs, Whippany NJ att!bromo!wtr now: AT&T Federal Systems, Burlington NC (919) 228 3673 (cornet 291)
EPRF%SNYCENVM.BITNET@cornellc.cit.cornell.edu (Peter Flass) (01/13/90)
On Wed, 10 Jan 90 19:33:20 GMT Paul Allen said: >In article <5067@ast.cs.vu.nl> ast@cs.vu.nl (Andy Tanenbaum) writes: >> >>I treid using cut yesterday to extract the third column from a crc listing >>like this: >> >>65261 8510 alloc.c >>09176 7432 break.c >>53152 990 const.h >> >>I could not find any combination of -d and -i flags to convince it to consider >>a run of spaces as a separator. I eventually did it with columns, but I >>think it ought to work with fields as well. Does anyone (e.g., the author) >>know how to do this? > Doesn't help with cut, but I use Mined to replace .*<space> with <nothing>, where <space> is a single blank and <nothing> is a carriage return to indicate a null replacement. - Pete +---------------------------------------------------------------------------+ | | | Peter Flass BITNET: EPRF@SNYCENVM (preferred) | | Director of Computing Services INTERNET: ESCFLASS@UBVM.CC.BUFFALO.EDU | | SUNY Empire State College AT&TNET: (518)587-2100 X350 | | 2 Union Avenue "After three days without programming, | | Saratoga Springs NY 12866 Life becomes meaningless" | | - The Tao of Programming | +---------------------------------------------------------------------------+
wbrown@loft386.UUCP (Wayne Brown) (01/13/90)
In article <5067@ast.cs.vu.nl>, ast@cs.vu.nl (Andy Tanenbaum) writes: > > I could not find any combination of -d and -i flags to convince it to consider > a run of spaces as a separator. You have to use the -d flag to redefine the delimiter as the space character, and also use the -i flag to use a run of spaces. The space must be enclosed in quotes. Try this : cut -i -d' ' -f3 filename to extract the third field. Wayne Brown uunet!loft386!ledgepc!wayne