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
echo $(cd $(dirname "$1") && pwd -P)/$(basename "$1")
This is explanation of what is going on at @ZeRemz's answer:
"$1"dirname "$1"cd "$(dirname "$1") into this relative dir && pwd -P and get absolute path for it. -P option will avoid all symlinks$(basename "$1")echo it