When it comes to command line text processing, there are several well known tools like grep for filtering, sed for substitution and awk for field processing. Compared to such tools, Ruby has a feature rich regular expression engine, plenty of builtin modules and a thriving ecosystem. Another advantage is that Ruby is more portable.
Ruby One-Liners Guide will show examples for filtering and substitution features, field processing, using standard and third-party modules, multiple file processing, how to construct solutions that depend on multiple records, how to compare records and fields between two or more files, how to identify duplicates while maintaining input order and so on.
This book heavily leans on examples to present features one by one. Exercises are also included to test your understanding.
You should be comfortable with programming basics and have prior experience working with Ruby. You should know concepts like blocks, be familiar with string/array/hash/enumerable methods, regular expressions etc.
You should be familiar with command line usage in a Unix-like environment. You should also be comfortable with concepts like file redirection and command pipelines. Knowing the basics of the
awk commands will come in handy as well.
You are also expected to get comfortable with reading manuals, searching online, visiting external links provided for further reading, tinkering with illustrated examples, asking for help when you are stuck and so on. In other words, be proactive and curious instead of just consuming the content passively.
This Ruby one-liners cookbook is incredible. Pretty mind boggling all the stuff you can do.
For a preview of the book, see sample chapters on GitHub.
Visit https://github.com/learnbyexample/learn_ruby_oneliners for markdown source, example files, exercise solutions and other details related to the book.
- One-liner introduction
- Line processing
- Field separators
- Record separators
- Multiple file input
- Processing multiple records
- Two file processing
- Dealing with duplicates
- Processing structured data
Feedback and Errata
I would highly appreciate it if you'd let me know how you felt about this ebook. It could be anything from a simple thank you, Gumroad rating, pointing out a typo, mistakes in code snippets, which aspects of the book worked for you (or didn't!) and so on. Reader feedback is essential and especially so for self-published authors.
You can reach me via:
- Issue Manager: https://github.com/learnbyexample/learn_ruby_oneliners/issues
- E-mail: firstname.lastname@example.org
- Twitter: https://twitter.com/learn_byexample
You'll get PDF and EPUB versions of the book.