Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
FileUtils.remove
(::FileUtils::pathlist list, ?force: ::boolish, ?noop: ::boolish, ?verbose: ::boolish) -> void
remove(list, force: nil, noop: nil, verbose: nil)
lib/fileutils.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/fileutils.rb, line 1242
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
Alias of .rm
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.