Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get full path of a file?

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 
like image 815
Jean Avatar asked Mar 10 '11 20:03

Jean


People also ask

What is full path of a file?

An absolute path refers to the complete details needed to locate a file or folder, starting from the root element and ending with the other subdirectories. Absolute paths are used in websites and operating systems for locating files and folders. An absolute path is also known as an absolute pathname or full path.

How do I find the full path of a file in Linux?

2.1. To obtain the full path of a file, we use the readlink command. readlink prints the absolute path of a symbolic link, but as a side-effect, it also prints the absolute path for a relative path. In the case of the first command, readlink resolves the relative path of foo/ to the absolute path of /home/example/foo/.


1 Answers

Use readlink:

readlink -f file.txt 
like image 109
filmor Avatar answered Oct 01 '22 12:10

filmor