Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.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?

share|improve this question

migrated from Aug 7 '10 at 23:12

This question came from our site for professional and enthusiast programmers.

try removing the quotation marks – klez Aug 7 '10 at 22:34
up vote 9 down vote accepted

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, that is where questions like this go.

share|improve this answer
Ah, thanks... however what if there were spaces in my path? How would I be able to handle that AND use wildcards? – Jake Petroules Aug 7 '10 at 22:35
if your folder is named, for example, test project, write test\ project, so you don't need qoutation marks – klez Aug 7 '10 at 22:37
@klez Perfect, thanks! – Jake Petroules Aug 7 '10 at 22:38
You know, if you answer the question here, it hardly gives the original questioner or anybody else for that matter, any incentive to ask the question where it belongs, on – Paul Tomblin Aug 7 '10 at 22:39
To answer the question about spaces in the file/path, you can use escapes (as klez said), or quote the part with spaces but leave the wildcard unquoted: /path/with spaces/filename prefix"* – Gordon Davisson Aug 8 '10 at 0:36

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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .