This is a question about Unix and shell programming. When you run a command like cp dir/* $destination
the shell has to do several things to simplify this command before executing it:
- Replace
dir/*
with a list of all the paths matching dir/*
e.g. dir/file1 dir/file2 dir/file3
- Replace
$destination
with the value of the variable destination
e.g. otherdir
There are other steps not shown here, like command substitution - for example $(ls)
is replaced by running the command ls
and replacing it with whatever ls
outputs.
Finally as a last step, generally separate from the others as it does not actually edit the command, the shell has to find the actual path of the cp
command, usually at /bin/cp
. It does this by looking at the variable PATH
, which holds a list of directories, then looking in each directory to find an executable called cp
.