Situatie
Solutie
How to Remove Files with rm
The simplest case is deleting a single file in the current directory. Type the rm command, a space, and then the name of the file you want to delete.
rm file_1.txt
If the file is not in the current working directory, provide a path to the file’s location.
rm ./path/to/the/file/file_1.txt
You can pass more than one filename to rm. Doing so deletes all of the specified files.
rm file_2.txt file_3.txt
Wildcards can be used to select groups of files to be deleted. The * represents multiple characters and the ? represents a single character. This command would delete all of the png image files in the current working directory.
rm *.png
This command would delete all files that have a single character extension. For example, this would delete File.1 and File.2, but not File.12.
rm *.?
If a file is write-protected you will be prompted before the file is deleted. You must respond with y or n and press “Enter.”
To reduce the risk of using rm with wildcards use the -i (interactive) option. This requires you to confirm the deletion of each file.
rm -i *.dat
The -f (force) option is the opposite of interactive. It does not prompt for confirmation even if files are write-protected.
rm -f filename
Leave A Comment?