I’d like to setup something like this in my .bashrc
export p1=`eval echo ~/projects/customer name/project name`
export p2=`eval echo ~/projects/customerb name/project name`
typing cd $p1 fails due to the spaces & I get directory not found issues.
I am aware that typing cd "$p1" (with speechmarks around variables) works.
How do I correctly setup my vars so that I can do things like this…
cd $p2
cp $p1/file $p2/
open $p1/lib
…without typing speechmarks each time?
Thanks in advance,
Nick
This is not a good idea. You should learn to deal with the shell as it is rather than rely on hacks to get behavior you find more aesthetically pleasing.
That said, you can achieve the effect you want by removing space from the
IFSvariable when assigningp1Sample:
Now it goes without saying, but I will say anyway to be clear, that you should not unset
IFSand leave it that way; most of the time the result won’t be what you expect. You should do so only for specific commands.Also, the term you’re looking for is “double-quote”, not “speechmark.” When googling, asking questions and searching for documentation in general it’s better to use the correct jargon.
EDIT:
Copy-paste friendly version: