Introduction
The shopt command allows you to set optional parameters for the shell.
shopt [-PSU] [optname ...]
-S turns on an option.
-U turns off an option.
-p lists all the options that can be set.
Extglob Options
If the EXTGLOB option is turned on, the shell will enable pattern matching. Reference to Shell pattern matching
See if the EXTGLOB option is on (default is OFF)
$ shopt Extglobextglob off
Turn on the EXTGLOB option
$ shopt-s Extglob
Check whether the EXTGLOB option is turned on at this
$ shopt extglob Extglob on
Turn off the EXTGLOB option
$ shopt-u Extglob
Instance
Move all files and directories under the directory to the backup directory.
3 files and two directories in the current directory
$ lsdir1 dir2 file1 file2 file3
Create a new backup directory
$ mkdir-p Backup
Move other files and directories other than the backup directory to the backup directory
$ mv! (Backup) backup/
View Results
$ lsbackup$ ls backup/dir1 dir2 file1 file2 file3
Delete all files or directories at the beginning of the file in the current directory
$ lsbackup dir1 dir2 file1 file2 file3$ rm-rf file[1-3]$ lsbackup dir1 Dir2
Move in addition to the Dir1 directory and the File1 file to the backup directory
$ mv! (dir1|file1|backup) backup/$ lsbackup dir1 file1$ ls backup/dir2 file2 file3
Other requirements also need to be extrapolate in combination with shell pattern matching.
Shell built-in command shopt extglob options