5/16/2013 - 3:54 PM

Shell commands to remove Files #shell

Shell commands to remove Files #shell

rm command syntax

rm (short for remove) is a Unix / Linux command which is used to delete files from a filesystem. Usually, on most filesystems, deleting a file requires write permission on the parent directory (and execute permission, in order to enter the directory in the first place). The syntax is as follows:

rm -f -r {file-name}


-f: Forcefully remove file
-r: Remove the contents of directories recursively
Remove or Delete a File

To remove a file called abc.txt type the following command:
$ rm abc.txt

To remove all files & subdirectories from a directory (MS-DOS deltree like command), enter:
$ rm -rf mydir

To remove empty directory use rmdir and not rm command:
$ rmdir mydirectory