rm
Remove a file or directory in ruby.
linux manual
Basic Usage
require 'kanrisuru'
host = Kanrisuru::Remote::Host.new(host: '127.0.1.1', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])
result = host.rm('file')
result.success?
true
Removing the root directory, '/' is disabled with Kanrisuru rm command.
Parameters
Field | Type | Description |
---|---|---|
paths |
string
array
|
Required name of the directory entries to remove |
recursive |
boolean
|
Recursively remove all directories and their contents |
force |
boolean
|
Attempt to remove the files without prompting for confirmation, regardless of the file's permissions. If the file does not exist, do not display a diagnostic message or modify the exit status to reflect an error. |
Result
No explicit data struct returned, only option is success?
, failure?
, and status
to see if the program exited properly.
Return Example
host.ls(path: 'directory').map(&:paths)
[
'file1',
'file2',
'file3',
'subdirectory1',
'subdirectory2',
'subdirectory3'
]
result = host.rm('directory', force: true, recursive: true)
result.success?
true
Exit Status
Code | Description |
---|---|
0 | Success |
1 | Failure |
Tested On
- Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES