Produce canonical path using a base directory.
Section: Path Basics
Resolve relative path from base
bash
bash
realpath --relative-to=/var/log /var/log/nginx/access.logLearn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Path Basics
Show current path via shell variable
Print current directory using shell state.
Convert relative path to absolute path
Resolve a relative path from current directory.
Iterate over files safely
Use NUL delimiters for filenames with spaces/newlines.
Test whether path exists
Check file or directory existence in shell scripts.