Remove unnecessary slashes from a given path with bash
bash, path
Solution
Use readlink:
p=$(readlink -m "/foo//////bar///hello/////world")
Notice that this will canonicalize symbolic links. If that's not what you want, use sed:
p=$(echo "/foo//////bar///hello/////world" | sed s#//*#/#g)
Problem
How can I get rid of unnecessary slashes in a given path? Example: ``` p="/foo//////bar///hello/////world" ``` I want: ``` p="/foo/bar/hello/world" ```