Ruby Command Line One Liners
Perl is particularly well known for its one-liners from the command prompt, but Ruby is pretty adept at it too. David P Thomas has put together a collection of about 100 Ruby one-liners in a single text file for us all to enjoy.
July 13, 2006 at 10:47 am
Or one could just use glark http://www.incava.org/projects/glark/ which is ruby grep with (optionally) highlighted output, ruby regexps, many features from gnu grep and the find command.
glark '/foo.*bar.*baz/' file
glark '/foo|bar|baz/' file
glark -0 regexp file
glark -0 --and=1 foo --and=1 bar baz file
glark -0 'foo.*bar.*baz' file
should do the above.
For other one liners there is:
http://wiki.rubygarden.org/Ruby/page/show/OneLiners
July 13, 2006 at 5:02 pm
None of those above examples SHOULD require "cat", should they? (Hearkening back to Randal Schwartz' "Useless use of 'cat'" awards days..."