Quote:
Originally Posted by
hanson44
I think this is so much simpler to write and maintain. If all you have is awk (or sed, or perl, or whatever), you are crippled. If you have them all in combination, within the context of a shell script, it's incredibly more powerful and easy for handling text data than DOS / Windows.
If all you have is perl, you are definitely not crippled. Far from it. If all you have is perl, you'll seldom have need for any of the other standard UNIX tools. With perl you can accomplish anything you can accomplish with awk, sed, grep, sort, cut, paste, ls, find, etc. It's distribution even includes a2p and s2p, which, respectively, automatically convert awk and sed scripts to perl scripts. Further, Perl provides access to system interfaces for which there is no standard utility, e.g. stat, and date/time facilities which embarrass the typical date implementation.
Most people who are advised to install cygwin to run sh scripts could easily do without, if they just knew perl.
To quote
Rob Pike from a nearly 10 year old Slashdot interview:
Quote:
8) One tool for one job? - by sczimme
Given the nature of current operating systems and applications, do you think the idea of "one tool doing one job well" has been abandoned? If so, do you think a return to this model would help bring some innovation back to software development?
(It's easier to toss a small, single-purpose app and start over than it is to toss a large, feature-laden app and start over.)
Pike:
Those days are dead and gone and the eulogy was delivered by Perl.
For the record, I'm not a fanboy defending his favorite language. Perl is a powerful tool, but I don't use it very often (although after writing this post, I think I should
).
Quote:
Originally Posted by
hanson44
A minor problem with the above script is that it sorts in ascending order, where I think perhaps you wanted descending order. I don't think it's a big deal. If nothing else, you could reverse the file with tac and start looking at the long words first.
Your code is identical to mine, except it uses a shell while-read loop instead of awk, and temp files instead of pipes. See my sort command (post #3) for how to fix yours.
Regards,
Alister