Neither Python nor Ruby are best suited for one-liners that the author is emphasising. One liners are bash-fu or commandline-fu. Anything above 100 lines (just a figure from the article) is what Python or Ruby should be used for.
Last 10 lines in a file? 'tail -10 filename.txt'
Right tools for the right job.
As to Python vs Ruby? I believe the argument isn't about the language (although I think Python is more 'sane' :) ), but the community that surrounds it. And I like the Python community.
The problem with using "the right tool for the right job" is that there are many tools and many jobs, and a general purpose language helps you get things done in case you're stuck. In general I use Ruby for doing string manipulation before piping to other commands.
Here's an (ugly) one liner that shows the biggest tables in a MySQL database:
mysql -u root godzilla -s -e 'show tables' \
| ruby -ne '$_.strip!; puts %Q{SELECT count(*) \
as cnt, "#$_" as tbl FROM #$_; }' \
| mysql -u root godzilla -s \
| sort -nr \
| ruby -ne 'parts = $_.split /\s+/; \
puts "%40s : %s" % parts.reverse' \
| head -10
You can probably come up with something more clever, but I barely gave that one any thought.
tail can be done in ruby can be quite succinctly with the $< (ARGF) variable:
ruby -e'$><<$<.map.last(10)'
For the rest of the ruby one-liners in the page the author references, most can be done more easily with standard command line tools (although most people aren't well-versed in sed, so 'ruby -pe puts' might be better than 'sed G').
There's one big problem with code like that. If you're doing devops-y stuff, then you really, really don't want to debug something like that when your pager goes off at 3am. The cleaner the solution the better, because after you wake up `$><<$<` is just a blurred thing with no meaning...
Last 10 lines in a file? 'tail -10 filename.txt'
Right tools for the right job.
As to Python vs Ruby? I believe the argument isn't about the language (although I think Python is more 'sane' :) ), but the community that surrounds it. And I like the Python community.