assigning a string with '/' from $1 to a variable
hi all
i tried this in numerous ways, but i just can't seem to make this work. i want to make an alias that takes a windows network path (\\blabla\bla\bla) and reverts the slashes (\\blabla\bla\bla > //blabla/bla/bla) then cd's into the output. if i do an #echo \\blabla\bla\bla | tr '\' '/' it works fine, but if i try to assign this to a variable, then it writes it with one slash and without the others in the argument , like so : /blablablabla even if the variable input comes form the #echo command. please help. this is annoying! |
Hi and welcome to LQ.
\ is an escape character and as such should be escaped. Try this: Code:
a=$(echo \\\\blabla\\bla\\bla | tr '\' '/') |
Or put the problem string in single quotes:
Code:
c@CW8:/tmp$ echo '\\blabla\bla\bla' | tr '\' '/' |
I am not sure I see the problem?
Code:
v='\\blabla\bla\bla' |
All times are GMT -5. The time now is 07:23 AM. |