Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Kernel#`

(::String arg0) -> ::String
`command` → string

Returns the $stdout output from running command in a subshell; sets global variable $? to the process status.

This method has potential security vulnerabilities if called with untrusted input; see Command Injection.

Examples:

$ `date`                 # => "Wed Apr  9 08:56:30 CDT 2003\n"
$ `echo oops && exit 99` # => "oops\n"
$ $?                     # => #<Process::Status: pid 17088 exit 99>
$ $?.status              # => 99>

The built-in syntax %x{...} uses this method.

See also .URI #abort .pp #Array also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0