bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic usage question involving "cut"


From: Bob Proulx
Subject: Re: Basic usage question involving "cut"
Date: Wed, 2 Aug 2006 02:13:12 -0600
User-agent: Mutt/1.5.9i

Linda Walsh wrote:
> Don't know if this is the appropriate place for this, but if it
> isn't possible, I could "suggest" that it might be considered a
> bug or at least a "design deficiency". :-)
> ...
> What I don't know how to do is how to select a "whitespace"
> delimited field.  It's one of the more common field delimiters I
> run into.  The easiest, but rather inefficient methods is to
> pipe the input into a shell-based "while read field1, field2..."
> loop, but it sure would make sense if there was an option
> to "cut" to handle white-space delimited fields.

But why try to use cut for that task when there are other better
suited tools?  I think the main reason cut has not needed to be
enhanced for all of these years is that awk does a better job of it.
Therefore there is no itch to scratch.  Just use a more appropriate
tool.

> Is there an option to "cut" that I don't know about, or am I
> looking in the wrong place for this type of functionality,
> or is this a feature "deficit", in "cut", that needs remedying?

Yes.  The best way to use 'cut' to split on whitespace is to spell it
'awk'.  ;-)

  echo one two three | awk '{print$2}'

And of course less standard options such as perl, python and ruby all
exist as well.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]