How can I execute commands in git-bash in windows which are located in a folder with spaces ie “Program Files”?

岁酱吖の 提交于 2019-12-01 04:07:26

Just put the command to execute between double quotes, like so

"C:\Program Files\whatever\aCmd.exe"

To reach the directory which has the spaces in it's path you just need to wrap the whole path with quotes. It should look like this:

cd "/c/Some Folder/Some Other Folder/"

Where there are special characters in a file name (spaces, $, parenthesis...) you need to place a backslash ahead of the character so that it reads it as is.

For example, if you want to run the program notepad++.exe straight from Bash and need to direct the path to:

C:\Program Files (x86)\Notepad++\

Then you would code the path in your bash.rc file as follows:

export PATH=$PATH:/c/Program\ Files\ \(x86\)/Notepad++:<path2>:<path3>:...<pathn>:

Note the backslashes leading the spaces and parentheses.

You can even add an additional line on the next line of your bash.rc file:

alias npp=notepad++

which will create a shortcut, allowing you to type npp straight into Bash, instead of having to type out the full program name notepad++ every time.

I'm a total noob, just started coding 4 days ago, though I found for this problem the best website was the following: http://www.grymoire.com/unix/Quote.html

Hope this helps! :D

Commands in git-bash accept paths within double quotes

"C:\Program Files\whatever\aCmd.exe"

or back slash for scaping the blank space

c/Program\ Files/whatever/aCmd.exe

Hope it helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!