Linux recursive delete directory under the file

Source: Internet
Author: User

Linux Delete folder instance:

Rm-rf/var/log/httpd/access
The/var/log/httpd/access directory and all the files and folders under it will be deleted
Linux Delete Folder command

Linux Delete file instance:

Rm-f/var/log/httpd/access.log
Will force deletion of/var/log/httpd/access.log this file
-R is recursive down, no matter how many levels of directory, delete
-F is simply forced to delete, without any hint of the meaning
-I for interactive deletion.


recursively delete files in directory

Direct RM is OK, but add two parameters-rf namely: RM-RF directory Name

-R is recursive down, no matter how many levels of directory, delete

-F is simply forced to delete, without any hint of the meaning

Find. -name ' *.exe '-type f-print-exec rm-rf {} \;

(1) "." means to start a recursive lookup from the current directory

(2) "-name ' *.exe '" to find by name, to find all folders or files ending with. exe

(3) "-type F" Lookup type is a file

(4) "-print" Output lookup file directory name

(5) The most important thing is the-exec, the-exec option follows a command to execute, indicating that the file or directory you are going to execute the command. The EXEC option follows the command or script to be executed, followed by a pair of {}, a space and a \, and finally a semicolon


need to be reminded: Use this RM-RF must be extra careful, Linux has no Recycle Bin

Of course, RM has more other parameters and usage, the input man RM can view the
Tip: Be careful with RM commands. Because once the file is deleted, it cannot be restored. Prevents this from happening, you can use the I option to confirm the files that you want to delete individually. If the user enters Y, the file is deleted. If you enter anything else, the file is not deleted.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.