realpath
Linux · Files · reference only
What it does
Converts a path into its canonical absolute form: it resolves ., .. and symbolic links.
Syntax
realpath [opciones] ruta...
Options and parameters
-eRequires every component to exist; otherwise it fails.
-mDoes not require any component to exist.
-sDoes not resolve symbolic links.
-qSuppresses error messages.
--relative-to=DIRPrints the path relative to that directory.
-zEnds each output line with a null character.
Usage examples
realpath ../notas.txtReturns the absolute path of notas.txt, one level above the current directory.
realpath -e /tmp/nadaFails because that path does not exist.
realpath --relative-to=/home/ana /home/ana/docs/a.txtReturns docs/a.txt, relative to /home/ana.
realpath -s enlaceReturns the link's absolute path without following it to its target.
Notes and common mistakes
- By default every component except the last must exist.