I don't think I ever fully grokked the rules of when and why one needs to doublequote things in Linux/Bash (I'm not sure if this problem's domain is Linux, Bash, or something else). I thought that *
matched any number of characters (including none), and this seems to align with Wikipedia's article. But when I tried to use the *
wildcard as follows, I got results I don't understand:
>pwd
/home/user/foo/foo/test
>tree
.
├─ main.opp
└─ test
└─ test.opp
>find ../ -name *.opp
../test/test.opp
>find ../ -name "*.opp"
../main.opp
../test/test.opp
>cd ..
>pwd
/home/user/foo/foo
>find . -name *.opp
./main.opp
>find . -name "*.opp"
./main.opp
./test/test.opp
Why does find
with the non-doublequoted *.opp
argument only return one hit, whereas doublequoting the same returns the expected two hits?