3 ms·
Hmmm, well that's why I like Ruby and other languages with functional approaches. Method chaining and blocks are very similar to pipes to me. cat /etc/pass
by jfhufl 8y ago
Hmmm, well that's why I like Ruby and other languages with functional approaches. Method chaining and blocks are very similar to pipes to me.
cat /etc/passwd | grep root | awk -F: '{print $3}'
ruby -e 'puts File.read("/etc/passwd").lines.select { |line| line.match(/root/) }.first.split(":")[2]'
A little more verbose, but the idea is the same.
https://alvinalexander.com/scala/fp-book/how-functional-programming-is-like-unix-pipelines https://alvinalexander.com/scala/fp-book/how-functional-prog...
- anthk 8y agoawk -F: '/root/ {print $3}' < /etc/passwd