Linux Command - rm
rm - remove files and dirs
rm file1.txt # remove file
rm -rf dir1 # recursive / force remove dir and contents
rm -rf dir1/* # recursive / force remove all in dir1
rm -rf * # recursive / force remove all
rm *.txt Remove all text files
| -f | don’t prompt, ignore files that don’t exist |
| -i | prompt first |
| -I | prompt if recursive or more than 3 files |
| –one-file-system | ignore anything on different file system |
| –no-preserve-root | don’t treat ‘/’ specially |
| -r | recursive |
| -R | recursive |
| -d | remove empty dirs |
| -v | verbose |
rm -- -test1 remove file starting with "-"
rm ./-test1 remove file starting with "-"