简体   繁体   中英

Linux how to use rm and exclude switch

I was wondering how we can use linux rm command with --exclude switch ?

For example like grep has exclude function when searching over the files.

Here is one specific

rm `find . -name "safe_room*" ! -name "safe_rooms.php"`

I used it mainly for git

git rm `find . -name "safe_room*" ! -name "safe_rooms.php"`

Explanation:

rm - linux command for delete

`` - the signs used within mysql. on keyboard CTRL + 7

find . -name "safe_room*" find . -name "safe_room*" - find everything with safe_room*

! - NOT logical operator

-name "safe_rooms.php" - exclude everything except safe_rooms.php

Hope this will help :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM