Show full path to file in terminal [duplicate]

I have a file. I'd like to echo out the full path to it in the terminal.

Which command would?


Use readlink with -e flag. Not only it gives you full path to file, it also presents real path of the symlinks

$ readlink -e ./out.txt                                                                                                  
/home/xieerqi/out.txt

I personally use it in my own scripts whenever it's necessary to get full path of a file


I found it:

sudo apt-get install realpath

Then:

realpath MY_FILE

If you don't know the location of the file use find command.

find / -name MY_FILE

It will print full path of MY_FILE starting from /.

or you can use find $PWD -name MY_FILE to search in current directory.

If you know the location of MY_FILE then go to folder containg MY_FILE and use

pwd command to print the full path of MY_FILE.