Method: FileUtils.rm
- Defined in:
- lib/fileutils.rb
permalink .rm(list, force: nil, noop: nil, verbose: nil) ⇒ Object
Removes entries at the paths in the given list
(a single path or an array of paths) returns list
, if it is an array, [list]
otherwise.
Argument list
or its elements should be interpretable as paths.
With no keyword arguments, removes files at the paths given in list
:
FileUtils.touch(['src0.txt', 'src0.dat'])
FileUtils.rm(['src0.dat', 'src0.txt']) # => ["src0.dat", "src0.txt"]
Keyword arguments:
-
force: true
- ignores raised exceptions of StandardError and its descendants. -
noop: true
- does not remove files; returnsnil
. -
verbose: true
- prints an equivalent command:FileUtils.rm(['src0.dat', 'src0.txt'], noop: true, verbose: true)
Output:
rm src0.dat src0.txt
Related: methods for deleting.
1217 1218 1219 1220 1221 1222 1223 1224 1225 |
# File 'lib/fileutils.rb', line 1217 def rm(list, force: nil, noop: nil, verbose: nil) list = fu_list(list) "rm#{force ? ' -f' : ''} #{list.join ' '}" if verbose return if noop list.each do |path| remove_file path, force end end |