#!/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)
}'