This is the development version of Kanrisuru. Since this is still a pre-1.0 release, we don't recommend using this in system-critical production environments.



Output contents of a file in ruby.
linux manual

Basic Usage

require 'kanrisuru'
host = '', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])

result ='/etc/hosts')

  [ 0] " localhost",
  [ 1] " ubuntu",
  [ 2] "",
  [ 3] .. [16],
  [17] "ff02::1 ip6-allnodes",
  [18] "ff02::2 ip6-allrouters",
  [19] "ff02::3 ip6-allhosts"


Field Type Description
path string
Required file path to get the contents from.
show_tabs boolean
Display tab characters
number boolean
number all output lines
squeeze_blank boolean
suppress repeated empty output lines
show_nonprinting boolean
use ^ and M- notation, except for LFD and TAB
show_ends boolean
display $ at end of each line
number_nonblank boolean
number nonempty output lines
show_all boolean
Show all fields including nonprinting, ends, and tabs
mode string
Can be either append or write options. Determines how content is saved into a file.
new_file string
The name of the newfile to write the content to


Either returns an array of all lines from the file, or a nil value if a file is being written to.

Additional Examples['~/ssl.csr', '~/'], 
  mode: 'write', 
  new_file: '/var/www/site/ssl/ssl.csr'

Exit Status

Code Description
0 Success
1 Failure

Tested On

  • Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES