Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symlinks in bash script aren't working

I'm writing a bash script on Mac OS X that makes a symlink but when I try and open the symlink that I created it doesn't go anywhere and I get an error that it can't find the original.

OriginalPath="~/PathTo/bundle1.bundle"
NewPath="/OtherPath/bundle1.bundle"
sudo ln -s $OriginalPath $NewPath

I've also tried this:

sudo ln -s ${OriginalPath} ${NewPath}
like image 939
JPC Avatar asked Apr 15 '26 18:04

JPC


1 Answers

ln sets the redirect to exactly what you give it, so it'll be interpreted relative to the location of the link. I'm actually not 100% sure how links will handle a ~, but I don't believe bash will expand it within quotes, and since it is a bash expansion, not a general filesystem one, I suspect the redirect will point to an actual directory named ~, which probably doesn't exist. Either figure out the relative path or expand it into an absolute path.

like image 54
Kevin Avatar answered Apr 18 '26 08:04

Kevin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!