Philip Ganchev wrote:

> 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

You're right, that's very clumsy, especially the "head -1" part which is
problematic.  (You should use the unambiguous "head -n 1" instead.)

> 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

How about:

perl -F'\t' -nae 'print join "\t", @F[2,4..$#F-3]' myfile

Brian


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to