This command is used to take away information. It may also be used to take away directories when it’s invoked with the -r possibility. However, test the rmdir command.

Basic syntax for rm command:

$ rm [OPTION...] [FILE...]
Delete a report
rm [file]

The rm command gets rid of a unmarried report. To try this, kind rm adopted by means of the title of the report you wish to have to delete.

Instance: Deleting the instance.txt report positioned within the /ExampleDir listing.

delete filedelete file
Take away information with out affirmation
rm -f [file]

This selection lets in customers to take away write-protected information with out affirmation.

Instance: Let’s delete the write-protected newfile.txt report.

delete file without confirmationdelete file without confirmation
Delete more than one information
rm [file1] [file2] [file3]

Use the rm command with filenames as arguments to take away more than one information immediately.

Instance: Disposing of a number of information new1, new2, new3 positioned within the /NameDir listing.

delete multiple filesdelete multiple files
Show output message
rm -v [filename]

The -v (verbose) possibility lets you get details about what’s being got rid of.

Instance: Deleting the instance.txt report and getting details about it.

display output messagedisplay output message
Recommended for affirmation sooner than deleting a report
rm -i [filename]

This selection is used to request affirmation sooner than deleting a report. Typing y (sure) confirms, typing n (no) stops.

Instance: When deleting the title.txt report, a affirmation message comes up. Input y to verify deletion.

confirmation before deleteconfirmation before delete

“rmdir”

This command gets rid of listing in addition to information throughout the listing. There isn’t vital distinction with the rm -r command aside from that it cannot be used to take away a report.

Basic syntax for rmdir command:

$ rmdir [OPTION...] [DIRECTORY...]
Take away a listing
rmdir [file]

Use this command to take away a listing, however it’s going to handiest be got rid of whether it is empty.

Instance: Getting into the rmdir command adopted by means of the listing title ExampleDir to take away it.

delete dirdelete dir
Delete more than one directories
rmdir [file1] [file2] [file3]

This command lets you delete a number of directories immediately, however all of them will have to be empty.

Instance: Deleting all directories new1, new2, and new3 on the similar time.

delete multiple dirdelete multiple dir
Take away mum or dad directories
rmdir -p [directory-path]

The -p possibility gets rid of the desired listing and its mum or dad directories.

Instance: Disposing of the listing trail newdir/dir1. The command gets rid of the newdir listing after deleting the dir1 listing.

delete parent directorydelete parent directory

The publish How to Delete Files and Folers in Linux seemed first on Hongkiat.

WordPress Website Development

[ continue ]