1
$ echo $billreminder
D:\juno_workspace_x64\9.0.4_app\moneycenter\src\webapp\jsp\billreminder

billreminder="${$billreminder/'D:'/ '\\cygdrive\\d' }"

(this returns BAD SUBSTUTION on cyg-win console windows)

i want to replace 'D:\' with '/cygdrive/d' in above string billreminder

5 Answers 5

2

Say:

billreminder="${billreminder/D:/\\cygdrive\\d}"
Sign up to request clarification or add additional context in comments.

1 Comment

this works , was giving bad substution error when a space was left between billreminder and /D:/ , and i didnt knew before it could work without quotes on strings , also the replacement string (in question) should have been in double quotes to escape /
1

You can you string substitution if you prefer, but using cygwin you can also use the command cygpath.
This command convert the parameter supplied as path in Windows-style to path in cygwin-style, you can use it as follow:

b=$(cygpath $b)

1 Comment

+1 this is the right way to work in CYGWIN environment, the other answers are playing around only (include the accepted one), which can't identify the difference of windows path (\) and Unix path (/).
1

You can use this substitution:

s='D:\juno_workspace_x64\9.0.4_app\moneycenter\src\webapp\jsp\billreminder'
echo "${s/D:\\//cygdrive/d\\}"
/cygdrive/d\juno_workspace_x64\9.0.4_app\moneycenter\src\webapp\jsp\billreminder

Comments

1

Simply remove the second $ sign:

~/> echo ${billreminder/'D:'/ '\\cygdrive\\d'}
\\cygdrive\\d\juno_workspace_x64\9.0.4_app\moneycenter\src\webapp\jsp\billreminder

Comments

0

you can do it this way:

b='D:\juno_workspace_x64\9.0.4_app\moneycenter\src\webapp\jsp\billreminder' 
b=\\cygdrive\\d\\${b#D:\\}
echo $b

2 Comments

i want to assign the result to a variable , echo /cygdrive/d/${b#D:\\} does not work here
it does: b=\\cygdrive\\d\\${b#D:\\} I'll do the edit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.