Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace space characters in paths with what?

Tags:

java

path

cygwin

I start bash from Java app and I have in my path for command which executes inside bash spaces ( example cd /Documents and Settings/test ), I run command with Process Builder but it doesn't work when path have spaces. I try to replace spaces with %20 but not help. What to do ?

like image 244
Damir Avatar asked Dec 02 '22 03:12

Damir


2 Answers

You can either encapsulate the full path in quotion marks like this:

String quoted = "\"" + pathString + "\"";

or, as you use bash, escape the spaces:

String escaped = pathString.replace(" ", "\\ ");

Both should work as an argument for your cd command.

like image 163
Andreas Dolk Avatar answered Dec 06 '22 09:12

Andreas Dolk


encapsulate the whole path between quotations.

cd "/Documents and Settings/test"
like image 38
fmucar Avatar answered Dec 06 '22 11:12

fmucar