Hi all!
I've got a little bash script that basically takes my directory path to the "My Documents" folder. Instead of the space, I've inserted a special sequence that I want replaced with "\ " so that I can cd into that directory. However, I get an interesting result.
Here's the Script:
#!/bin/bash
MYDIR=/users/cs/study/gordon/MyxyXYWhitespacEYXyxDocuments
MYDIR=${MYDIR//xyXYWhitespacEYXyx/\\\ }
echo $MYDIR
cd $MYDIR
ls
Here's the output when I run my file:
/users/cs/study/gordon/My\ Documents
./test: line 5: cd: /users/cs/study/gordon/My\: No such file or directory
So the echo shows that the "\ " was put into the variable, but when I try and cd into it, it cuts off at the "My\". Does the string substitution put in something unique instead of just a whitespace? Am I using this correctly?
Thanks in advance for any insight.
