Ruby Command-Line Options

Following is a complete list of Ruby’s command-line options roughly organized by functionality.

Options That Determine What Ruby Runs

-0[octal]

The 0 flag (the digit zero) specifies the record separator character (\0, if no digit follows). -00 indicates paragraph mode: records are separated by two successive default record separator characters. 0777 reads the entire file at once (because it’s an illegal character). Sets $/.

-a

Autosplit mode when used with -n or -p; equivalent to executing $F = $_.split at the top of each loop iteration.

-c

Checks syntax only; does not execute the program.

--copyright

Prints the copyright notice and exits.

-e ’command

Executes command as one line of Ruby source. Several -es are allowed, ...

Get Programming Ruby 3.3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.