🐧 Linux / Shell Scripting
Beginner
How do you use wildcards (globbing) in Linux?
Answer
Shell wildcards (globs) expand to match filenames. * matches any sequence of characters (except leading dots): ls *.txt lists all .txt files. ? matches any single character: ls file?.txt matches file1.txt, fileA.txt. [abc] matches any one character in the set: ls [abc]*.sh. [0-9] matches any digit. {jpg,png,gif} is brace expansion (not globbing) matching listed alternatives: cp *.{jpg,png} /backup/. Globbing is done by the shell before passing arguments to commands. Use quotes to prevent glob expansion when passing patterns to tools like find or grep.
Previous
What is the difference between single quotes and double quotes in bash?
Next
What is piping in Linux?