wmii/util/cleanname
2007-07-01 15:26:14 -04:00

19 lines
273 B
Bash
Executable File

#!/bin/sh -f
echo "$@" |
awk -F'/+' '{
delete a
n = 0
for(i = 1; i <= NF; i++) {
if($i == ".." && n > 0 && a[n] != "..")
n--
else if($i != "" && $i != ".")
a[++n] = $i
}
s = ""
for(i = 1; i <= n; i++)
s = s "/" a[i]
print substr(s, 2)
}'