Interpreted object-oriented scripting language
|
-F pattern Specifies input field separator ($;).
|
-l (The lowercase letter “ell”.) Enables automatic line-ending processing, which means to
firstly set $\ to the value of $/, and secondly chops every line read using chop!.
|
-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.
|
-n Causes Ruby to assume the following loop around your script, which makes it iterate over
file name arguments somewhat like sed -n or awk.
while gets
...
end
|
-p Acts mostly same as -n switch, but print the value of variable $_ at the each end of the
loop. For example:
% echo matz | ruby -p -e '$_.tr! "a-z", "A-Z"'
MATZ
|
-e command Specifies script from command-line while telling Ruby not to search the rest of the
arguments for a script file name.
|
-i extension Specifies in-place-edit mode. The extension, if specified, is added to old file name to
make a backup copy. For example:
% echo matz > /tmp/junk
% cat /tmp/junk
matz
% ruby -p -i.bak -e '$_.upcase!' /tmp/junk
% cat /tmp/junk
MATZ
% cat /tmp/junk.bak
matz
|
-0[octal] (The digit “zero”.) Specifies the input record separator ($/) as an octal number. If no
digit is given, the null character is taken as the separator. Other switches may follow the
digits. -00 turns Ruby into paragraph mode. -0777 makes Ruby read whole file at once as a
single string since there is no legal character with that value.
|