Re:Skip grep, use awk
by vidarh on Tuesday July 04, 2017 @09:32AM
(#14695741)
Here's the equivalent for Ruby:
Or:
(Of course Ruby got the -a autosplit-mode and the -n assumed 'while gets(); ... end' loop from Perl along with $_ and $F, so it's very intentional that they're similar)
[ Parent
| on HN ]
Somewhat related nodejs self plug: Use nip https://github.com/kolodny/nip
$ echo -e 'this\nis\na\nwhatever foo' | nip 'return /whatever/.test(line) && cols[1]' # fooAwesome thanks for sharing this! I was too lazy to give a Ruby example alongside.
And Ruby regexes are amazing.