For example, let's assume I have those files in my current work directory:
demo.txt
, text.txt
, temp.txt
, audio.mp3
.
When I run this command in the shell:
ls *.txt
What happened under the neath?
Does shell expand it to ls demo.txt text.txt temp.txt
first and put it into argv
then fork ls
?
Or does it do nothing but put ls *.txt
directly into argv
and then fork ls
?
In Linux (and Unix variants in general) wildcard expansion is done by the shell before invoking the command. (Unless explicitly suppressed with quotes.)
In other operating systems (e.g. DOS, Windows) wildcards are always passed verbatim and their expansion is the responsibility of the command.