Rm


From Linuxconfig.org

Jump to: navigation, search

.. back to the list of Linux Commands

Name

rm - remove files or directories

Synopsis - man page

rm [OPTION]... FILE...

Frequently used options

-i, --interactive
      prompt before any removal
-f, --force
      ignore nonexistent files, never prompt
-r, -R, --recursive
      remove directories and their contents recursively

Examples

Interactive remove is very useful option.

rm -i foo.bar

Image:rm_i.gif

rm -f ( force) option removes also files which are protected from writing without asking.

rm -f foo.bar

Image:rm_f.gif

Even that rm command was not constructed to remove directories by default you can force rm to remove directory and all files in inside by -fr option combination. Be very careful with this command it can do lots of damage:

rm -fr dir/

Image:rm_fr.gif

Sometimes you need to make rm command to do not accept any other options. Lets assume that we have a file called "-i" and we need to remove it. In this case we nee to use "--" options wich will instruct rm command to not accept any other options.

rm -- -i

Image:rm_0.gif

Or we might need to remove filename which starts with meta character. In this case we need to escape this meta character with "\". For example to remove $rm file we issue command:

rm \$rm

Image:rm_1.gif

.. back to the list of Linux Commands

Personal tools
Linux Commands