Linux retains several files and deletes others
The set Option and shopt option are two different groups of content. You can use set-o and shopt-p to view all the open and closed entries of the two groups respectively. By default, some are open and some are closed. The shopt options will increase with the bash version update. The basic operations related to shopt are as follows:
# Shopt-p listing all options
# Shopt-s: list all open options
# Shopt-s extglob enable extglob Option
# Shopt-u list all disabled options
# Shopt-u extglob disable extglob Option
Description:
Cdspell when a cd directory is entered, if the directory name is accidentally wrong, a letter is wrong or missing, you can also enter the directory.
A hidden file starting with a dot in dotglob can be represented as a wildcard, just like other files.
Extglob can use rm! (* Jpg) to delete all file names that do not end with jpg. You can also use rm * @ (jpg | png) to represent "or". Of course, there are other .....
When using bash, you need to familiarize yourself with these options and find the settings that suit your taste.
A total of 9 files, except for retaining files 1, 2, and 3, are deleted.
[Report @ localhost ~ /Tmp] $ ls
1 2 3 4 5 6 7 8 9
[Report @ localhost ~ /Tmp] $ shopt-s extglob
[Report @ localhost ~ /Tmp] $ rm-rf! (1 | 2 | 3)
[Report @ localhost ~ /Tmp] $ ls
1 2 3
[Report @ localhost ~ /Tmp] $ shopt-u extglob
This article permanently updates the link address: