RM excludes files under the specified file or specified folder

Source: Internet
Author: User
3, Method 3, the current folder in combination with grep and xargs to process the file name: ls | Grep-v Keep | Xargs RM #删除keep文件之外的所有文件说明: LS First gets the name of all current files and folders, Grep-v Keep, the grep regular match lookup keep,-v parameter determines the result to match the results, that is, to the keep of all file names , then Xargs is used to get the parameters from the standard input and passed to the following command, where the command used is RM, and then the file selected by RM is deleted. Benefit: Using grep to match the file name with a regular expression, you can keep multiple files at a time for more accurate processing. 4, Method 4, using the Find command instead of LS, improve method 3 to be able to work with the file of the development folder: Find./test/| Grep-v Keep | Xargs rm #删除当前test文件夹中keep文件之外的所有文件说明, use grep instead of Find-name to select the name, because find is troublesome to choose the name, the regular expression support is not enough to exclude the specified file name.

RM excludes files under the specified file or specified folder

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.