coreutils
[Top][All Lists]
Advanced

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

Re: cut -DF


From: Pádraig Brady
Subject: Re: cut -DF
Date: Sat, 15 Jan 2022 11:18:41 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:95.0) Gecko/20100101 Thunderbird/95.0

On 15/01/2022 08:44, Shehu Dikko wrote:
* Rob Landley [2022-01-05] [gmane.comp.gnu.coreutils.general]:
Around 5 years ago toybox added the -D, -F, and -O options to cut:

     -D  Don't sort/collate selections or match -fF lines without delimiter
     -F  Select fields separated by DELIM regex
     -O  Output delimiter (default one space for -F, input delim for -f)

This lets you do:

   $ echo one two three four five six seven eight nine | cut -DF 7,1-3,2
   seven one two three two

Nice to see that one can specify a range of fields which is not
something that is as straigtforward with awk. I have also seen that it's
undocumented but one can also do the even more useful:

$ echo one two three four five six seven eight nine | cut -DF 1,5-$
one five six seven eight nine

Do please also add the undocumented feature to cut.

For now, it's alias cut='toybox cut'

Open ended ranges are already supported by coreutils cut:

  $ echo one two three four five six seven eight nine | cut -d ' ' -f 1,5-
  one five six seven eight nine

I don't think we need to support an explicit '$' for this.

cheers,
Pádraig



reply via email to

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