Neat collection of Ruby one-liners

Neat collection of Ruby one-liners
Average rating: 0
(0 votes)

Thanks! You’ve rated this material!

Meet this huge collection of Ruby one-liners! Mostly file oriented stuff, like adding blank lines into files, adding line numbers into text files, counting lines, selective printing of certain lines… But very useful. As a bonus, you’ll find the links to the other lists with different Ruby one-liners!

To start from, the concept of a one-liner program has been known since the 1960s with the release of the APL programming language. With its terse syntax and powerful mathematical operators, APL allowed useful programs to be represented in a few symbols.

Benoit Hamelin created this list himself, and it is worth sharing! He made a list of

Ruby one-liners


  1. File spacing
  2. Numbering and calculations
  3. String creation
  4. Array creation
  5. Text conversion and substitution
  6. Selective printing of certain lines
  7. Selective deletion of certain lines

Find them all in the original Benoit’s blog post!

More Ruby one-liners:

  1. Smooth Ruby One-Liners list by Ryan Palo
  2. A very huge collection of Ruby one-liners by Sundeep Agarwal

Also, read our article about 5 Ruby methods for solving specific types of problems.

Rate this article, if you like it

Thanks! You’ve rated this material!

Got a project? Let's discuss it!

    Kyiv Sofiivska 1/2a, 01001, Kyiv, Ukraine
    Dnipro Hlinky 2, of. 1003, 49000, Dnipro, Ukraine
    Kharkiv Otakara Yarosha 22, 61000, Kharkiv, Ukraine
    Email [email protected]