I often use |awk '{print $5;}'(replace 5with columns with one index of your choice) in pipelines. You can get similar simple single-line s rubyif you use a few funny command line switches. For comparison:
$ ls -l | awk '{print $5;}'
404
16
10
8733
against
$ ls -l | ruby -ne "a = split; puts a[4];"
nil
404
16
10
8733
ruby -n while gets() do .. end , ruby -e script . , , perl -ne awk(1).
manpage , :
-a Turns on auto-split mode when used with -n or
-p. In auto-split mode, Ruby executes
$F = $_.split
at beginning of each loop.
, ( bash(1) $F[3] ).:
$ ls -l | ruby -ane 'puts $F[3]'
nil
root
root
root
root
sarnold
sarnold
...