Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Ruby Command Line One Liners

By Peter Cooper / July 13, 2006

Oneliners

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.

Comments

  1. hgs says:

    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

  2. Michael says:

    None of those above examples SHOULD require "cat", should they? (Hearkening back to Randal Schwartz' "Useless use of 'cat'" awards days..."

Other Posts to Enjoy

Twitter Mentions