(coreutils.info)Realpath usage examples


Up: realpath invocation
Enter node , (file) or (file)node

18.5.1 Realpath usage examples
------------------------------

By default, ‘realpath’ prints the absolute file name of given files
(symlinks are resolved, ‘words’ is resolved to ‘american-english’):

     cd /home/user
     realpath /usr/bin/sort /tmp/foo /usr/share/dict/words 1.txt
     ⇒ /usr/bin/sort
     ⇒ /tmp/foo
     ⇒ /usr/share/dict/american-english
     ⇒ /home/user/1.txt

   With ‘--relative-to’, file names are printed relative to the given
directory:

     realpath --relative-to=/usr/bin \
              /usr/bin/sort /tmp/foo /usr/share/dict/words 1.txt
     ⇒ sort
     ⇒ ../../tmp/foo
     ⇒ ../share/dict/american-english
     ⇒ ../../home/user/1.txt

   With ‘--relative-base’, relative file names are printed _if_ the
resolved file name is below the given base directory.  For files outside
the base directory absolute file names are printed:

     realpath --relative-base=/usr \
              /usr/bin/sort /tmp/foo /usr/share/dict/words 1.txt
     ⇒ bin/sort
     ⇒ /tmp/foo
     ⇒ share/dict/american-english
     ⇒ /home/user/1.txt

   When both ‘--relative-to=DIR1’ and ‘--relative-base=DIR2’ are used,
file names are printed relative to DIR1 _if_ they are located below
DIR2.  If the files are not below DIR2, they are printed as absolute
file names:

     realpath --relative-to=/usr/bin --relative-base=/usr \
              /usr/bin/sort /tmp/foo /usr/share/dict/words 1.txt
     ⇒ sort
     ⇒ /tmp/foo
     ⇒ ../share/dict/american-english
     ⇒ /home/user/1.txt

   When both ‘--relative-to=DIR1’ and ‘--relative-base=DIR2’ are used,
DIR1 _must_ be a subdirectory of DIR2.  Otherwise, ‘realpath’ prints
absolutes file names.


automatically generated by info2www version 1.2.2.9