shadow0wolf
shadow0wolf

Reputation: 171

String substution in BASH

$ 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

Upvotes: 1

Views: 85

Answers (5)

antoniochiurla
antoniochiurla

Reputation: 72

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)

Upvotes: 1

Jakub Kotowski
Jakub Kotowski

Reputation: 7571

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

Upvotes: 0

Ivaylo Strandjev
Ivaylo Strandjev

Reputation: 70929

Simply remove the second $ sign:

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

Upvotes: 1

devnull
devnull

Reputation: 123508

Say:

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

Upvotes: 2

anubhava
anubhava

Reputation: 785196

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

Upvotes: 1

Related Questions