Michal Suchanek wrote:
> On 1/6/06, Robert Klemme <bob.news / gmx.net> wrote:
>> Danny Abc wrote:
>>> I'm new to Ruby and was wondering how to sort a text file?
>>>
>>> With UNIX scripts, I just use "cat input.txt | sort > output.txt".
>>
>> You are entitled to the "useless cat award".  :-) Any reason why you
>> don't just do
>> "sort input.txt > output.txt"?
>
> Well, cat does not write its arguments so you are pretty sure it is
> the input argument whatever command you put next in the pipeline.

I'm sorry, what do you mean by that?  Do you mean to say that cat only
reads and so there is no danger of overwriting a file?  Unix command line
tools that acutally write to a file named on the command line are rather
seldom; there are quite a few that use an option for that.  Never occurred
to me that this extra level of security was needed.

> Plus there was a shell once where input redirection did not work and
> one replaced it with cat and |. At least that is how I learned to use
> useless cats extensively.

You don't need a shell without redirection - sort sorts the files named on
its command line.  I doubt it ever behaved differently.

> Anyway, cats are nice :)

Certainly!  See http://www.flickr.com/photos/99776024@N00/sets/1697461/

Kind regards

    robert