zsh Main differences from bash Wildcard Handling


Example

When nothing matches a wildcard such as * in bash, it gets passed on as a literal * to the command, as if you had typed \*. However, zsh throws an error.

Bash:

duncan@K7DXS-Laptop-Arch:~/test$ echo *.txt
*.txt
duncan@K7DXS-Laptop-Arch:~/test$ touch abc.txt
duncan@K7DXS-Laptop-Arch:~/test$ echo *.txt
abc.txt
duncan@K7DXS-Laptop-Arch:~/test$ 

Zsh:

K7DXS-Laptop-Arch% echo *.txt   
abc.txt
K7DXS-Laptop-Arch% rm abc.txt 
K7DXS-Laptop-Arch% echo *.txt
zsh: no matches found: *.txt
K7DXS-Laptop-Arch% 

This is most noticeable in programs that use a literal *, such as find:

duncan@K7DXS-Laptop-Arch:~/test$ ls -R
.:
abc

./abc:
123.txt

Bash:

duncan@K7DXS-Laptop-Arch:~/test$ find -name *.txt
./abc/123.txt
duncan@K7DXS-Laptop-Arch:~/test$ 

Zsh:

K7DXS-Laptop-Arch% find -name *.txt
zsh: no matches found: *.txt
K7DXS-Laptop-Arch% find -name \*.txt
./abc/123.txt
K7DXS-Laptop-Arch% find -name '*.txt' # Notice single rather than double quotes
./abc/123.txt
K7DXS-Laptop-Arch%