11 lines
221 B
Bash
Executable file
11 lines
221 B
Bash
Executable file
#!/bin/sh
|
|
p="${1%/}"
|
|
target=$(readlink "$p")
|
|
|
|
case "$target" in
|
|
/*) p="$target";;
|
|
'') ;;
|
|
*) p="${p%/*}/$target";;
|
|
esac
|
|
|
|
printf "%s\n" "$p"|sed -e 's@/[^/]*/\.\.\(/\|$\)@/@g' -e 's|/\.\(/\|$\)|/|g' -e 's|/$||g' -e '/^$/d'
|