Thursday, July 21, 2016

Finding the absolute path of a symlink file

If a file is in your present working directory, I could easily find the absolute path of the file by typing `pwd` in the terminal.

But, how would I deal with the following situation? (scroll to the complete right)

The symlink is not made of absolute path. But, I want to know the file's absolute path with a single command.


$ ls -lh Q1527_v2*
lrwxrwxrwx. 1 prakkisr bio-info   71 Jun 27 10:27 Q1527_v2_scaffolds_63ContaminantRemoved_facheck.fasta -> ../SIPE_LIB_REAPR/Q1527_v2_scaffolds_63ContaminantRemoved_facheck.fasta

I searched across and found a beautiful utility called readlink


$ readlink -f ../SIPE_LIB_REAPR/Q1527_v2_scaffolds_63ContaminantRemoved_facheck.fasta
/stor2/Genome/scaffolds/Q1527_v2_63ContaminantsRemoved/Reapr/SIPE_LIB_REAPR/Q1527_v2_scaffolds_63ContaminantRemoved_facheck.fasta

No comments:

Post a Comment