# Extended Globbing

Much like the order of operations in mathematics, Bash evaluates these shell expansions in a specific order.

1. Brace Expansion
   * `{1..8}`
2. Tilde Expansion
   * `~/`
3. Parameter Expansion
   * `$USER , $USERID`
4. Variable Expansion
   * `$(who | tail -n10 | awk '{print $2}')`
5. Arithmetic Expansion & Command Substitution (left to right)
   * `$(($USERID + 12 ))`
6. Word Splitting
7. Filename Expansion
   * `.*`
8. Quote Removal
   * `"$USER"`

ENABLING EXTENDED GLOBBING

`shopt -s extglob`

LEARNNN

```bash
cd PracticeFiles
touch Logfile_{0{0..9},1{1..2}}_{1..30}_202{0..2}.{txt,log}.{csv,xlsx,pdf}; touch Logfile_{0{0..9},1{1..2}}_{1..30}_202{0..2}.{txt,log}; touch Backup_{0{0..9},1{1..2}}_{1..30}_202{0..2}.{txt,log}.{csv,xlsx,pdf}; touch Backup_{0{0..9},1{1..2}}_{1..30}_202{0..2}.{txt,log}; touch corgi.{png,jpg,raw
mkdir {Logs,Backups}
#Be sure to enable extended globbing before continuing:
shopt -s extglob
#Use the ls command to list the files that match this pattern
ls @(Logfile)*@(@(.log|.txt)@(.csv|.xlsx|.pdf))
#Now that we’ve matched the proper files, we can move them to the Logs directory using them mv command.
mv @(Logfile)*@(@(.log|.txt)@(.csv|.xlsx|.pdf)) Logs
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://taqiyeddine.gitbook.io/exploring-it/devops/bash-scripting-and-system-configuration-certificate-notes/bash-scripting-and-system-configuration/week2/extended-globbing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
