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

Re: why does "cut" print fields in original order?

On 21Nov2007 02:12, Robert P. J. Day <rpjday crashcourse ca> wrote:
| On Wed, 21 Nov 2007, Frank Cox wrote:
| > On Wed, 21 Nov 2007 01:44:26 -0500 (EST)
| > "Robert P. J. Day" <rpjday crashcourse ca> wrote:
| > > i understand that that's not indicated on the man page.  on the
| > > other hand, is there any reason that it *wasn't* done that way?

Because cut is a data pruning tool, not a reporting tool.

| > > it would seem that that would be an obvious enhancement and,
| > > certainly, that would be more intuitive behaviour, no?

It would never have occured to me to cut fields out of order.

You've got awk et al for reporting.

| > It would be fairly trivial to "roll your own" if you require that
| > functionality.
| yes, i realize that -- i'm just baffled why that wasn't the obvious
| behaviour in the first place.  i mean, i'm trying to imagine the
| brainstorming session:
| A:  "and if the user asks for fields 1 and 2, we'll print 1 and 2."
| B:  "yup, i'm all over that."
| A:  "and if he asks for 2 and 1 ... i know, we'll still print 1, then
|     2.  hahahaha!  oh, man, sometimes i crack me up!"

Or... "Hmm, I only want a few fields from the input,so I'll write a tool
to crop the input on demand."

Once you realise that cut _cuts_ stuff it's all obvious. It doesn't
start with a blank output and fill stuff in, it starts with a filled in
line and cuts stuff out.

| i'm just curious what kind of thinking went into doing something so
| non-intuitive.

I'm not. You're reading more into the command than the author intended,
because you have the wrong mental model of its purpose.

| after all, if you ask "awk" to print given fields, it
| does what you expect.

And again: cut is not filling things in. It's cutting things out.
Cameron Simpson <cs zip com au> DoD#743

Peeve:  Going to our favorite breakfast place, only to find that they were
        hit by a car...AND WE MISSED IT.
                - Don Baldwin, <donb netcom com>

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