How to get full path of a file?

Jean picture Jean · Mar 10, 2011 · Viewed 1M times · Source

Is there an easy way I can print the full path of file.txt ?

file.txt = /nfs/an/disks/jj/home/dir/file.txt

The <command>

dir> <command> file.txt  

should print

/nfs/an/disks/jj/home/dir/file.txt

Answer

filmor picture filmor · Mar 10, 2011

Use readlink:

readlink -f file.txt