How to show full path of a file including the full filename in Mac OSX terminal?

Use realpath

E.g.:

$ realpath README.md 
/Users/joe/my/long/directory/structure/README.md

Answered here on stackoverflow: https://stackoverflow.com/a/3915075/441960

Make sure you download the coreutils on Homebrew as it isn't installed by default on all macs:

brew install coreutils

FYI, my version of MacOS (OSX):

$ uname -a
Darwin my-machine 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64

From here: https://stackoverflow.com/a/4031502/804713

macports and homebrew provide a coreutils package containing greadlink (GNU readlink). credit to Michael Kallweitt post in mackb.com

brew install coreutils

greadlink -f file.txt


There are many ways to do that; here is one example that may work for you:

claw:~ jonv$ echo `pwd`/`ls config.in.php`
/Users/jonv/config.in.php

If you want more examples, there are a bunch on this post at stackoverflow.


In Mac OSX, do the following steps:

  1. cd into the directory of the target file.
  2. Type either of the following terminal commands.
Terminal
ls "`pwd`/file.txt"
echo $(pwd)/file.txt
  1. Replace file.txt with your actual file name.
  2. Press Enter.

You can also use the "find" command for listing all files with complete path:

find DirectoryName -type f

or just the following:

find . -type f