LukeShortCloud / rootpages

Root Pages is a collection of easy-to-reference tutorials and guides primarily for Linux and other UNIX-like systems.
Other
56 stars 6 forks source link

[programming][shell] Exclude files from a glob #1119

Open LukeShortCloud opened 7 months ago

LukeShortCloud commented 7 months ago

This is useful for deleting all files in a directory except for a select few. For example:

$ shopt -s extglob
$ rm -r -f /home/!("foobaruser")

https://askubuntu.com/questions/889744/what-is-the-purpose-of-shopt-s-extglob