With options -e
, -n
, -p
, perl can do what grep/awk/sed can, what about ruby?
Let's take the result of ls -l
as input and process it with ruby
\ls -l | ruby -ne 'print if /^d/'
\ls -l | ruby -ne 'puts split(/\s+/).last if /^d/'
\ls -l | ruby -pe 'gsub /.*\s+(\S+)$/, %q|\1|'
\ls -l | ruby -pe 'gsub(/.*\s+(\S+)$/) {$1.capitalize}'