Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Aug 7 '10 at 23:12

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

2  
try removing the quotation marks –  klez Aug 7 '10 at 22:34

2 Answers 2

up vote 7 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 superuser.com, 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
1  
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 superuser.com. –  Paul Tomblin Aug 7 '10 at 22:39
1  
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.