Revision: 67327
Updated Code
at September 9, 2014 22:59 by biiont
Updated Code
# Prepare mkdir -p "${HOME}/path without/symlinks"; ln -s "${HOME}/path without" "${HOME}/path with" TESTPATH="${HOME}/..///${USER}/path with/symlinks///"; echo "${TESTPATH}" echo "Absolute path: '$(realpath -m ${TESTPATH})'" echo "Canonical path: '$(realpath -s -m ${TESTPATH})'" echo "Relative to '/usr/bin': '$(realpath -s -m --relative-to="/usr/bin" ${TESTPATH})'" echo "Canonical relative to '/usr/bin': '$(realpath -m --relative-to="/usr/bin" ${TESTPATH})'" echo "Relative with base '/usr/bin': '$(realpath -s -m --relative-base="/usr/bin" ${TESTPATH})'" echo "Relative with base '${HOME}': '$(realpath -s -m --relative-base="${HOME}" ${TESTPATH})'" echo "Canonical relative with base '${HOME}': '$(realpath -m --relative-base="${HOME}" ${TESTPATH})'" echo "Basedir: '$(dirname "$(realpath -s -m ${TESTPATH})")'" # BASEDIR="$(dirname "$(realpath -s ${0})")" # Cleanup rm -rf "${HOME}/path with" "${HOME}/path without"
Revision: 67326
Updated Code
at September 9, 2014 22:49 by biiont
Updated Code
# Prepare mkdir -p "${HOME}/path without/symlinks"; ln -s "${HOME}/path without" "${HOME}/path with" TESTPATH="${HOME}/..///${USER}/path with/symlinks///"; echo "${TESTPATH}" echo "Absolute path: '$(realpath -m ${TESTPATH})'" echo "Canonical path: '$(realpath -s -m ${TESTPATH})'" echo "Relative to '/usr/bin': '$(realpath -s -m --relative-to="/usr/bin" ${TESTPATH})'" echo "Canonical relative to '/usr/bin': '$(realpath -m --relative-to="/usr/bin" ${TESTPATH})'" echo "Relative with base '/usr/bin': '$(realpath -s -m --relative-base="/usr/bin" ${TESTPATH})'" echo "Relative with base '${HOME}': '$(realpath -s -m --relative-base="${HOME}" ${TESTPATH})'" echo "Canonical relative with base '${HOME}': '$(realpath -m --relative-base="${HOME}" ${TESTPATH})'" # Cleanup rm -rf "${HOME}/path with" "${HOME}/path without"
Revision: 67325
Updated Code
at September 9, 2014 21:31 by biiont
Updated Code
CANONPATH="$(realpath -s -m "${HOME}/../path with/spaces///")"; ls "${CANONPATH}"
Revision: 67324
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 9, 2014 21:29 by biiont
Initial Code
CANONPATH="$(realpath -s -m "${HOME}/path/with spaces")"; ls "${CANONPATH}"
Initial URL
Initial Description
Canonical, Absolute and Relative Paths in POSIX Shell
Initial Title
Canonical, Absolute and Relative Paths in POSIX Shell
Initial Tags
Initial Language
Bash