Is there an easy way I can print the full path of file.txt ?
file.txt
file.txt = /nfs/an/disks/jj/home/dir/file.txt
The
This will work for both file and folder:
getAbsolutePath(){ [[ -d $1 ]] && { cd "$1"; echo "$(pwd -P)"; } || { cd "$(dirname "$1")" || exit 1; echo "$(pwd -P)/$(basename "$1")"; } }