How do wildcards match several filenames in a command-line argument?
Quick answer
Wildcards are pattern characters, commonly * for zero or more characters and ? for a character position. Their meaning depends on the shell and sometimes on the program receiving the argument. In Bash, unquoted wildcards are usually expanded by the shell before a command runs; in PowerShell, wildcard support depends on the command parameter. First list the matches in your own shell, check the results, and only then use the pattern elsewhere.
The question, the details, the next step.
A practical checklist
Identify your shell and the command that will receive the pattern.
Use a listing-only command to inspect matches in the intended location.
Check how the pattern handles dot-prefixed names and no matches.
Confirm that the specific command argument accepts wildcards.
Proceed only when every listed filename is intended.
A few more useful answers
Does `*` match hidden files?
In Bash, names beginning with . generally require a pattern with an explicit leading dot unless the dotglob setting is enabled. Do not assume this rule applies unchanged in another shell. [S1]
Will the same wildcard work in Bash and PowerShell?
How can I pass a wildcard character literally in PowerShell?
PowerShell documentation describes escaping wildcard characters or using -LiteralPath for filenames that contain literal wildcard characters. Check that the command supports the option. [S2]
Sources
References used for this guide.
- [S1] GNU Bash Reference Manual: Filename Expansion gnu.org · Checked
- [S2] PowerShell 7.6: about_Wildcards learn.microsoft.com · Checked
