in reply to get string/array slices using cut-like specifications


Which version of cut?
$ cat b.txt 123456789 $ cut -c 6-4,2,8,8,8,8 b.txt 28 $ gcut -c 6-4,2,8,8,8,8 b.txt gcut: invalid decreasing range Try `gcut --help' for more information. $ gcut --version cut (GNU coreutils) 7.5 Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gp +l.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by David M. Ihnat, David MacKenzie, and Jim Meyering.

My cut came with FreeBSD 6.4.

Replies are listed 'Best First'.
Re^2: get string/array slices using cut-like specifications
by jdporter (Paladin) on Mar 10, 2011 at 12:27 UTC

    Hm. Right. I was going by the man page linked at cut. It says, "selected input is written in the same order that it is read." I took that to mean that arbitrary order is supported and respected. What else could it mean? But I don't see any explicit mention of non-increasing order. And it does explicitly state that each "selected input... is written exactly once." I find that either vague or redundant. What is a "selected input"? If "2" occurs in the spec twice, doesn't that make the second element a selected input twice, both of which are to be written exactly once? In any case, my perl version is at least as general, if not more so, than the cut version. :-)

    Obviously there are other things cut can do which I have not (yet) implemented here.

    I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.