Is there a more Bashist way than echo "$PWD//" | sed -e 's#//\+#/#g' to replace repeating slashes with a single one?
Thanks Steven D, now there's a fully working function to find the longest common path of two or more paths: path_common.
|
Is there a more Bashist way than Thanks Steven D, now there's a fully working function to find the longest common path of two or more paths: path_common. |
||||
|
|
|
Not a "Bash-only" answer, but perhaps useful:
|
|||||||
|
|
Possible in "pure bash", but only with
|
|||
|
UPDATE: Mat(+1) has got the right idea... my answer only works for odd numbers of "/" it does not need "extglob" to be set. var="$PWD///"; var="${var//\/\//}" ; echo "$var" |
||||
|
|