4

I’m having a problem with filenames having whitespace in a bash script on Mac OSX:

name="My File" #file name
version="1.0.0"

echo "Copying AAX..."
mkdir aax/
cp -R "/Library/Application Support/Avid/Audio/Plug-Ins/""${name}".aaxplugin aax

echo "Copying AU..."
mkdir au/
cp -R "~/Library/Audio/Plug-Ins/Components/""${name}".component au

echo "Copying VST2..."
mkdir vst/
cp -R "~/Library/Audio/Plug-Ins/VST/""${name}".vst vst

It goes perfectly fine with the AAX file, but it won’t find the file for AU and VST. I tried quoting different parts of the command lines, but I always get “no such file or directory” for those two.

What’s wrong there?

Thanks!

1 Answer 1

1

Two things:

  1. Tilde (~) does not expand in quotes; use $HOME instead if you want to use it that way.
  2. If you want to use tilde then only ${name} should be double-quoted (to prevent word-splitting).

So that would look like this (1):

"$HOME/Library/Audio/Plug-Ins/Components/${name}".component au

Or like this (2):

~/Library/Audio/Plug-Ins/Components/"${name}".component au
Sign up to request clarification or add additional context in comments.

3 Comments

Aren't the curly braces redundant with double quotes ?
@Httqm: it would still need to be double-quoted; often curly brackets are used for better readability.
Thanks. I didn't know that the tilde wouldn't expand while quoted. Now it works as expected.

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.