2 ms·
One could replace the first Ruby script by a Ruby one-liner too: ruby -e "puts File.read('/tmp/com.txt').scan(/^[^.]+/).uniq" Personally I almost never use an
by kouteiheika 4y ago
One could replace the first Ruby script by a Ruby one-liner too:
ruby -e "puts File.read('/tmp/com.txt').scan(/^[^.]+/).uniq"
Personally I almost never use any of the standard Unix tools like `awk` etc. since an equivalent Ruby script is almost always shorter and easier to write. (There are exceptions of course; and in really simple cases the standard tools will obviously still win.)
I think it's a shame that Ruby never really got popular as a general purpose scripting language, since it has that nice property that it's often as short as Perl while still being readable.