In both cases, your interactive bash is expanding ./*.md
before calling find
. So your first command expands to this:
find ./one.md ./two.md ./three.md ./four.md
In the second case, your command expands to this:
./findall.sh ./one.md ./two.md ./three.md ./four.md
Then the script runs, and expands the command in the script to this:
find ./one.md
Perhaps you meant to quote the wildcard:
find './*.md'
./findall.sh './*.md'
But in either case, find
will fail because the first arguments to find
(before any arguments that start with -
) are the names of directories in which to search. There is no directory whose name is ./*.md
, because /
cannot occur in a file or directory name.
Perhaps you meant this, to find all files whose names match *.md
, anywhere under the current directory:
find . -name '*.md'
Perhaps you meant this, to find all files in the current directory (but not subdirectories) whose names match *.md
:
find . -maxdepth 1 -name '*.md'