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

command linemacos

'ls' can show the file name, e.g

ls config.inc.php
config.inc.php 

'pwd' show current folder full path, e.g

pwd
/Application/XAMPP/xamppfiles/phpmyadmin

Is there a command can put them together, would be able to show:

/Application/XAMPP/xamppfiles/phpmyadmin/config.inc.php

Best Answer

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
Related Question