I wanted to delete all the files from a directory except one. I found my solution here. This solution is using this command:
shopt -s extglob
I want to know what this command exactly does, some back end knowledge.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
In simple terms, globbing refers to pattern matching. Bash uses simple globbing like,
echo l* which expand to list of files in current directory that start with letter
l. Of course , as you can guess, it's simple and limited.
extglob. As you can guess, it stands for
extended globbing. This option allows for more advanced pattern matching. From
extglob If set, the extended pattern matching features described above under Pathname Expansion are enabled.
And a little before that:
If the extglob shell option is enabled using the shopt builtin, several extended pattern matching operators are recognized. In the following description, a pattern-list is a list of one or more patterns separated by a |. Composite patterns may be formed using one or more of the following sub-patterns: ?(pattern-list) Matches zero or one occurrence of the given patterns *(pattern-list) Matches zero or more occurrences of the given patterns +(pattern-list) Matches one or more occurrences of the given patterns @(pattern-list) Matches one of the given patterns !(pattern-list) Matches anything except one of the given patterns