Next: The Question Mark
Up: Wildcards
Previous: Wildcards
Good question. Actually, there are a couple of special characters
intercepted by the shell, bash . The character
``*'', an asterix, says ``replace this word with all the files
that will fit this specification''. So, the command cp data*
~/backup, like the one above, gets changed to cp
data-new data1 data2 data5 ~/backup before it gets run.
To illustrate this, let me introduce a new command,
echo . echo is an extremely simple command;
it echoes back, or prints out, any parameters. Thus:
As you can see, the shell expands the wildcard and passes all of the
files to the program you tell it to run. This raises an interesting
question: what happens if there are no files that meet the
wildcard specification? Try echo /rc/fr*og and see what
happens...bash will pass the wildcard
specification verbatim to the program.
One word about that, though. Other shells, like
tcsh , will, instead of just passing the wildcard
verbatim, will reply No match.
The last question you might want to know is what if I wanted to have
data* echoed back at me, instead of the list of file names?
Well, under both bash and tcsh, just include the string in
quotes:
OR
Converted on:
Mon Apr 1 08:59:56 EST 1996
|