YouTip LogoYouTip

Ruby Command Line Options

# Ruby Command Line Options Ruby is generally run from the command line as follows: $ ruby [.] [ arguments ... ] The interpreter can be invoked with the following options to control the interpreter's environment and behavior. | Option | Description | | --- | --- | | **-a** | When used with -n or -p, enables auto split mode. See the -n and -p options. | | **-c** | Checks syntax only, does not execute the program. | | **-C dir** | Changes directory before execution (equivalent to -X). | | **-d** | Enables debug mode (equivalent to -debug). | | **-F pat** | Specifies pat as the default field separator ($;). | | **-e prog** | Specifies prog as the program to execute from the command line. Multiple -e options can be used to execute multiple programs. | | **-h** | Displays an overview of command line options. | | **-i ** | Rewrites file contents as program output. The original file is saved with the extension ext. If ext is not specified, the original file is deleted. | | **-I dir** | Adds dir as a directory for loading libraries. | | **-K ** | Specifies multibyte character set encoding. e or E corresponds to EUC (extended Unix code), s or S corresponds to SJIS (Shift-JIS), u or U corresponds to UTF-8, a, A, n or N corresponds to ASCII. | | **-l** | Enables automatic line ending processing. Removes a newline character from input lines and appends a newline character to output lines. | | **-n** | Places the code in an input loop (as if in while gets; ... end). | | **-0** | Sets the default record separator ($/) to octal. If octal is not specified, the default is . | | **-p** | Places the code in an input loop. Outputs the value of variable $_ after each iteration. | | **-r lib** | Uses _require_ to load _lib_ as a library before execution. | | **-s** | Interprets any arguments matching the pattern -xxx between the program name and filename arguments as switches and defines corresponding variables. | | **-T ** | Sets the security level, performing taint checks (if level is not specified, the default is 1). | | **-v** | Displays version and enables verbose mode. | | **-w** | Enables verbose mode. If no program file is specified, reads from STDIN. | | **-x ** | Deletes text before the #!ruby line. If _dir_ is specified, changes directory to _dir_. | | **-X dir** | Changes directory before execution (equivalent to -C). | | **-y** | Enables parser debug mode. | | **--copyright** | Displays copyright notice. | | **--debug** | Enables debug mode (equivalent to -d). | | **--help** | Displays an overview of command line options (equivalent to -h). | | **--version** | Displays version. | | **--verbose** | Enables verbose mode (equivalent to -v). Sets $VERBOSE to true. | | **--yydebug** | Enables parser debug mode (equivalent to -y). | Single-character command line options can be combined. The following two lines express the same meaning: $ ruby -ne 'print if /Ruby/' /usr/share/bin $ ruby -n -e 'print if /Ruby/' /usr/share/bin
← Ruby Environment VariablesRuby Installation Windows β†’