cmdxray / commands / realpath

What does realpath do?

resolve a path to its absolute, symlink-free canonical form.

▸ Explain your own realpath command →

realpath examples, explained

$ realpath ./file.txt

  • realpathresolve a path to its absolute, symlink-free canonical form
  • ./file.txtan argument passed to the command

$ realpath -m /a/b/missing

  • realpathresolve a path to its absolute, symlink-free canonical form
  • -mallow missing components — resolve the path anyway
  • /a/b/missingan argument passed to the command

$ realpath --relative-to /home /home/user/x

  • realpathresolve a path to its absolute, symlink-free canonical form
  • --relative-toprint the result relative to the given directory
  • /homevalue for --relative-to
  • /home/user/xan argument passed to the command

realpath flags & options

-erequire every path component to exist (error otherwise)
-mallow missing components — resolve the path anyway
-sdon't expand symlinks (only collapse . and .. and slashes)
-zend each output line with NUL instead of a newline
--relative-toprint the result relative to the given directory
--relative-baseprint relative when under this dir, else absolute

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.