I have a string like "/directory/username" and I want to use a bash script to change this to "/directory-username". This is what I have tried:
path="/directory/username"
path=$($path | sed -r 's/(.*)\//\1-/')
Here is the output:
bash: /directory/username: No such file or directory
What is it that I have failed to understand?