10

In my .sh file, I have this, cp $file $SOME_PATH, while $SOME_PATH is exported as export SOME_PATH="~/path/to/path/". But when I ran this .sh file, I got error message saying like no such "~/path/to/path/" exists. I replaced ~ as $HOME, then the error was gone. So what's up here with the tilde?

Thanks in advance.

jdhao
  • 24,001
  • 18
  • 134
  • 273
dutor
  • 137
  • 1
  • 6

2 Answers2

9

use

SOME_PATH=~/path/to/path/

if you path have spaces, quote it

SOME_PATH=~/"path with spaces"
ghostdog74
  • 327,991
  • 56
  • 259
  • 343
2

Remove the quotation marks on your export:

export SOME_PATH=~/path/to/path/
chrisaycock
  • 36,470
  • 14
  • 88
  • 125