bug-coreutils
[Top][All Lists]
Advanced

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

Re: [coreutils] "cut" from last column


From: Bauke Jan Douma
Subject: Re: [coreutils] "cut" from last column
Date: Sat, 02 Dec 2006 23:54:53 +0100
User-agent: Thunderbird 1.5.0.8 (X11/20061025)

Philip Ganchev wrote on 02-12-06 23:33:
Hi

I have a suggestion to allow the "cut" command to understand column
(field) numbers relative to the last column.  I find I need this
functionality very often when working with tabular data.  Currently,
the expression to achieve this is clumsy:

cut -f 3,5-$(echo $(head -1 myfile | wc -w) - 3 | bc) myfile

The new syntax could use +1 to specify the last column, +2 to specify
the second-last, etc.  This syntax is the same as for the "tail"
command.  Then you can achieve the same as the above expression by
writing:

cut -f 3,5-+3 myfile

Couldn't you use rev(1).  If you're using Linux, it's in
the util-linux package.
rev < myfile | cut -something | rev

bjd





reply via email to

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