After struggling with the same problem, I tried two different solutions that work:
1. Use double quotation marks ( "" ) with your variables.
The easiest way is to simply quote your variables as indicated in the previous answer:
cd "$yourPathWithBlankSpace"
2. Use eval .
According to this Unix response command, to escape spaces you can remove the space and then use eval , for example:
yourPathEscaped=$(printf %q "$yourPathWithBlankSpace") eval cd $yourPathEscaped
HanniBaL90 Dec 03 '17 at 10:43 on 2017-12-03 10:43
source share