rm - command in linux
rm command removes the given file., with -r option it will remove the directories
syntax
rm [options] [filenames|directories]
example
//below command removes the file(s)
rm myfile.txt
rm myfile1.txt myfile2.txt
//below command removes the directories
rm -r mydir
rm -r mydir2 mydir3
force remove
//below command force removes the file
rm -f myfile.txt
//below command force removes the directories
rm -rf mydir
options
Option | Description |
---|---|
-f, --force | force removes files, will not prompt if file not exists |
-i | prompt user when removing file(s) |
-I | prompt user when removing a set of 3 files |
--interactive[=WHEN] | prompt user based on WHEN parameter |
--one-file-system | |
--no-preserve-root | |
--preserve-root | |
-r, -R, --recursive | remove directories and their contents recursively |
-v, --verbose | explain what is being done |
--help | displays help info of rm command |
--version | displays version info of rm command |