End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
FileUtils.remove
remove(list, force: nil, noop: nil, verbose: nil)
lib/fileutils.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/lib/fileutils.rb, line 1230
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
FileUtils.remove is an alias for FileUtils.rm.
Related: methods for deleting.