Bash script to cd to directory with spaces in pathname

后端 未结 13 1756
旧时难觅i
旧时难觅i 2020-11-28 21:14

I\'m using Bash on macOS X and I\'d like to create a simple executable script file that would change to another directory when it\'s run. However, the path to that director

相关标签:
13条回答
  • 2020-11-28 21:44

    This will do it:

    cd ~/My\ Code
    

    I've had to use that to work with files stored in the iCloud Drive. You won't want to use double quotes (") as then it must be an absolute path. In other words, you can't combine double quotes with tilde (~).

    By way of example I had to use this for a recent project:

    cd ~/Library/Mobile\ Documents/com~apple~CloudDocs/Documents/Documents\ -\ My\ iMac/Project
    

    I hope that helps.

    0 讨论(0)
提交回复
热议问题