Reputation: 1824
When I run my script locally I can sanitise strings perfectly and remove slashes:
get_branch_name () {
local branch_name="$(git name-rev --name-only HEAD)"
echo $branch_name
}
feature_branch_name="$(get_branch_name)"
feature_branch_name_no_backslash=$(echo $feature_branch_name | sed 's/\//-/')
However on my remote Linux server sed
does not work and I have not been able to make this work at all so far, using whichever combination of solutions I find on the web.
I want to replace slashes with dashes as it is used as a file name and slashes will create sub folders.
How can I achieve this with substitution or sed?
Upvotes: 0
Views: 422
Reputation: 12877
Use parameter expansion with from/to:
feature_branch_name_no_backslash=${feature_branch_name//\//-}
Upvotes: 1