Reputation: 221
I have a shell script variable as follows
a='\bin\tem\abc\xyz.sh'
I must remove the xyz.sh from the path and need to store it in a another variable called b. That is b must contain '\bin\tem\abc\'.
Upvotes: 0
Views: 46
Reputation: 3646
You can use Parameter Expansion:
b="${a%\\*}\\"
This removes the trailing \
and everything after it before appending with \
.
Upvotes: 1