class method
FileUtils.rm
(::FileUtils::pathlist list, ?force: ::boolish, ?noop: ::boolish, ?verbose: ::boolish) -> void
rm(list, force: nil, noop: nil, verbose: nil)
lib/fileutils.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/fileutils.rb, line 1213
def rm(list, force: nil, noop: nil, verbose: nil)
list = fu_list(list)
fu_output_message "rm#{force ? ' -f' : ''} #{list.join ' '}" if verbose
return if noop
list.each do |path|
remove_file path, force
end
end
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:
Example
FileUtils.touch(['src0.txt', 'src0.dat']) FileUtils.rm(['src0.dat', 'src0.txt']) # => ["src0.dat", "src0.txt"]
Keyword arguments:
-
force: true- ignores raised exceptions ofStandardErrorand its descendants. -
noop: true- does not remove files; returnsnil. -
verbose: true- prints an equivalent command:ExampleFileUtils.rm(['src0.dat', 'src0.txt'], noop: true, verbose: true)
Output:
Examplerm src0.dat src0.txt
Related: methods for deleting.