Reputation:
This question is related to this one.
I have this variable:
var=/myprefix/something/something-else
And this prefix:
prefix=/myprefix/
I want to remove the prefix
. We can do this in a non-greedy way as follows:
echo ${var#/myprefix/}
Which gives:
something/something-else
as expected. How can I use the prefix
variable instead of hard-coding the prefix?
Upvotes: 0
Views: 120
Reputation: 44371
What about:
echo ${var#${prefix}}
Here you have some documentation, and here the bash manual.
Upvotes: 2