cp command not working with wildcards on Mac OS X
I am using the following command on a Mac OS X machine:
cp "/Users/username/Desktop/silverlock-dev/silverlock/../3rdparty/botan-build-desktop/src/libBotan*" "/Users/username/Desktop/silverlock-dev/silverlock-build-desktop/silverlocklib/../bin"
However I get:
cp: /Users/username/Desktop/silverlock-dev/silverlock/../3rdparty/botan-build-desktop/src/libBotan*: No such file or directory
There are clearly 4 files in that directory called:
libBotan.1.0.0.dylib
libBotan.1.0.dylib (symlink to first file)
libBotan.1.dylib (symlink to first file)
libBotan.dylib (symlink to first file)
If I spell out the full name of the file in the copy command, it works fine, but I need to be able to use wildcard as part of a build process. Logic and reason tells me this should work without issue. Am I missing something simple?
When you put the * in quotes, it expects that to be the literal filename rather than doing a match-all expansion. Just take out the quotes and this will work. Also, check out superuser.com, that is where questions like this go.
When the shell expands wildcards in your command line, it first splits on spaces, then expands wildcards. The expanded filenames (which may contain spaces) are each passed as a complete argument to the command (cp
).
Note that the command (cp
in this case) never sees the quotes you use on the shell command line and does not split its own arguments on spaces. It receives a list of unquoted strings, each of which may contain spaces.