Luca Capozzi
Luca Capozzi

Reputation: 43

Bash script and whitespaces in file names

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!

Upvotes: 4

Views: 210

Answers (1)

l'L'l
l'L'l

Reputation: 47169

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

Upvotes: 1

Related Questions