Pwd with space paths but on the parameter don't work

hi, i'm finding to solve on the parameter:

for example:

directory Value 1

root@value 1 > pwd
/home/user/root/value 1

root@value 1 > pwd | sed 's/ /\\ /g'
/home/user/root/value\ 1

root@value 1 > test="$(pwd | sed 's/ /\\ /g')"
root@value 1 > echo "$test"
/home/user/root/value\ 1

root@value 1 > cd "$test"
-bash: cd: home/user/root/value\ 1: No such file or directory

Why don't work? thanks

no need to escape the space. Just do test=$(pwd) and cd "$test"

1 Like

i need when the path have the space

on the bash script don't work when found the path with space

Hello,

You can do as follows also for same.

cd "Value 1"

It should help you.

Thanks,
R. Singh

You are trught.
It's just thanks much.
only inserting " " on $test and solve all.
thanks much