Ruby Command Line Options
Ruby is generally run from the command line, as follows:
$ ruby [ options ] [.] [ programfile ] [ arguments ... ]
The interpreter can be invoked through the following options to control the environment and the behavior of the interpreter.
Options | description |
---|---|
-a | When used with -n or -p, can be opened automatically split mode (auto split mode). See the -n and -p option. |
-c | Just check the syntax without executing the program. |
-C thee | Change directory before executing (equivalent to -X). |
-d | Enable debug mode (equivalent to -debug). |
-F pat | Pat designated as the default mode of separation ($;). |
-e prog | Prog designated as a program executed from the command line. You can specify multiple -e option to execute multiple programs. |
-h | Displays an overview of the command-line options. |
-i [ ext] | Rewriting the contents of the file output program. The original file will be saved with the extension ext. If ext is specified, the original file will be deleted. |
And say | Add dir as a directory to load libraries. |
-K [ kcode] | Multi-byte character sets specified encoding. e or E corresponds EUC (extended Unix code), s or S corresponding to SJIS (Shift-JIS), u corresponding to U or UTF-8, a, A, n, or N corresponds to ASCII. |
-l | Enable automatic end of line handling. Cancel a newline from input line and output line append a newline character. |
-n | The input code is placed in a loop (as in gets while; ... end of the same). |
-0[ octal] | Set the default record separator ($ /) as an octal. If not specified, the default is octal. |
-p | The input code is placed in a loop. The value of output variable $ _ after each iteration. |
-r lib | Use require to load lib as a library before execution. |
-s | Any parameter matching pattern between the program name and the file name of the interpretation parameter -xxx as the switch, and the definition of the corresponding variable. |
-T [level] | Set the security level, do not purity test (level, if not specified, the default value is 1). |
-v | Display version and enable redundancy mode. |
-w | Enable redundant mode. If the file is not specified, reads from STDIN. |
-x [dir] | Remove the #! Ruby text before the line. If you specify dir , put the directory is changed to dir . |
-X you | Change directory before performing (equivalent to -C). |
-and | Parser debug mode is enabled. |
--copyright | Display the copyright notice. |
--debug | Enable debug mode (equivalent to -d). |
--help | Displays an overview of command-line options (equivalent to -h). |
--version | Display version. |
--verbose | Enable redundant mode (equivalent to -v). $ VERBOSE is set to true. |
--yydebug | Enable the parser debug mode (equivalent to -y). |
Single-character command-line options can be combined. The following two lines expressed the same meaning:
$ruby -ne 'print if /Ruby/' /usr/share/bin
$ruby -n -e 'print if /Ruby/' /usr/share/bin
This switched: http://codingdict.com/article/6830