why does "cut" print fields in original order?

Tony Nelson tonynelson at georgeanelson.com
Wed Nov 21 19:31:55 UTC 2007

At 10:57 AM -0500 11/21/07, Robert P. J. Day wrote:
>On Wed, 21 Nov 2007, Dave Ihnat wrote:
>> Actually, I originally wrote cut & paste, but after the initial release,
>> left it on its own.  Thankfully, David MacKenzie and Jim Meyering (neither
>> of whom I've ever met or communicated with) picked up the ball and kept
>> working on the programs.  (And whatever prompted me to spend the time to
>> recreate these programs?  I was working on a Unix clone called 'Venix',
>> and was annoyed that it didn't have these commands.)
>> I wrote the programs to be as close to identical to the original Unix
>> System 5 man page as I could, and "reverse-engineered" it from the man
>> page description of behavior and options, deliberately not ever referring
>> to or accessing the original source, since it was copyrighted material
>> of AT&T.  At the time I was reverse engineering it, I asked numerous
>> questions on Usenet as to whether I should fix obvious bugs or deviations
>> in behavior, or extend the command; the overwhelming response was "make
>> it behave like the 'real' command".
>> Now, as to why it does what it does?  I don't know for sure, since
>> I didn't go find whoever wrote the original and ask.  But I can
>> guess--"do one thing, and do it well."  Cut is supposed to get fields
>> from a line-delimited data stream.  Period.  Rearrangement is an added
>> function--one that might be useful, certainly; but that can be done via
>> other shell tools.
>yes, i now appreciate that cut's behaviour is the very efficient
>technique of treating the data as a one-way stream, so i'm good with
>that.  so lay off already.  ya hear me??  LAY OFF!!!

This all rather begs the question of what tool to use after cut in order to
reorder the fields?  Don't pretend the answer is sed or awk, or their ilk.
TonyN.:'                       <mailto:tonynelson at georgeanelson.com>
      '                              <http://www.georgeanelson.com/>

More information about the fedora-list mailing list