[Top][All Lists]

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

[coreutils] "cut" from last column

From: Philip Ganchev
Subject: [coreutils] "cut" from last column
Date: Sat, 2 Dec 2006 17:33:50 -0500


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

cut -f 3,5-+3 myfile

reply via email to

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