Home » linux » Linux and Unix rm command tutorial with examples

Linux and Unix rm command tutorial with examples

“rm” command is used to remove/delete files.
this command can delete more than one file at a time.
“rm” command can also delete the specific file from the directory.

Syntax:

Example:

Suppose we want to delete a file Mybook01 then the command is as follows:

Note: File ones delete can’t be regained.

Delete more than one file at a time: “rm” command can also delete more then one file at a time.

Suppose we want to delete files Mybook01, Mybook02 and Mybook03 than the command is as follows:

Above command delete three files (Mybook01, Mybook02 and Mybook03 ) at a time.

Delete all file at a time: “rm” command can also delete all file at a time using *.

Above command delete all files in a directory.

Delete a specific file from a directory:
Suppose we want to delete a file Mybook01 and Mybook02 from Book directory then the command as follows:

Option of “rm” command

Interactive Deletion (i): option –i(interactive) ask and confirms from the user before deleting a file.
Suppose we want to delete two files Myook01 and Mybook02 than interactive deletion option “-i ” ask from the user before delete this files as shown in below command

If we press y then the file will be deleted and if press n then it will leave file undeleted.

Managed by MochaHost - Fast & Easy WordPress Hosting