-2

The following command:

cp "/Users/my.name/Documents/GitHub/Folder/*.dylib" "/Users/my.name/Documents/GitHub/OtherFolder"

Throws the following:

No such file or directory

The following command:

cp "/Users/my.name/Documents/GitHub/Folder/theFile.dylib" "/Users/my.name/Documents/GitHub/OtherFolder"

Copy the file.

The following commands:

cd "/Users/my.name/Documents/GitHub/Folder/"
cp *.dylib "/Users/my.name/Documents/GitHub/OtherFolder"

This leads me to believe this is due to the presence of quotes "...". Same when using '...'. Why is that ? What can I do if the path contains spaces ?

1 Answer 1

1

In a unix shell (bash, zsh, etc.), you can quote any portion of the string (with double quotes or single quotes), you don't have to quote the entire string. e.g.

bll-g7:bll$ mkdir -p $HOME/'dq"'/"sq'"/stuff
bll-g7:bll$ ls -ld $HOME/'dq"'/"sq'"/stuff
drwxr-xr-x 2 bll bll 4096 Jun 10 08:33 /home/bll/dq"/sq'/stuff/

In the case of wild cards, you can do:

cp "/Users/my.name/Documents/folder with space/lib/"*.dylib \
   $HOME/somewhere/
Sign up to request clarification or add additional context in comments.

2 Comments

ok but what is the logic about that ? Why can't wild cards be surrounded by quotes ?
When a wild card is quoted, the shell will not expand it, it preserves the character. When you quote something, you want the actual value, not the expansion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.