get the full path of a file

Turn a file's name into its whole path from /, through links if you want.

  • files

Steps

  1. realpath file.txt

    its absolute path, links resolved

  2. readlink -f file.txt

    the same, on older systems

  3. echo "$PWD/file.txt"

    this folder's path plus the name

  4. find "$PWD" -name '*.txt'

    every .txt file under here, with full paths

  5. pwd

    the folder you are in

Commands used

  • realpath
  • readlink
  • pwd

Each has a page in lore: lore realpath opens it.