Extended Globbing
Much like the order of operations in mathematics, Bash evaluates these shell expansions in a specific order.
Brace Expansion
{1..8}
Tilde Expansion
~/
Parameter Expansion
$USER , $USERID
Variable Expansion
$(who | tail -n10 | awk '{print $2}')
Arithmetic Expansion & Command Substitution (left to right)
$(($USERID + 12 ))
Word Splitting
Filename Expansion
.*
Quote Removal
"$USER"
ENABLING EXTENDED GLOBBING
shopt -s extglob
LEARNNN
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
Last updated