5

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?

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

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

10

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.

  • 1
    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 – Federico klez Culloca Aug 7 '10 at 22:37
  • 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
  • I did say in my question that this is part of a build process, therefore it seems to me it would belong on SO, not SU. If I were just trying to move files around it would make sense to put it on SU, but this does relate to software development. I do see your point, however - it's kind of hard to place it directly on one side or the other. – Jake Petroules Aug 7 '10 at 22:40
  • 3
    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
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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