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
3
  • Aren't the curly braces redundant with double quotes ?
    – Httqm
    Commented May 15, 2019 at 10:54
  • @Httqm: it would still need to be double-quoted; often curly brackets are used for better readability.
    – l'L'l
    Commented May 15, 2019 at 10:58
  • Thanks. I didn't know that the tilde wouldn't expand while quoted. Now it works as expected. Commented May 15, 2019 at 14:23

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