This works with multiple delimiters and does not assume that this path should exist:
p=/foo///.//bar///foo1/bar1//foo2/./bar2; echo $p | awk '{while(index($1,"/./")) gsub("/./","/"); while(index($1,"//")) gsub("//","/"); print $1;}'
But does not simplify lines containing ".."
Feri
source share