Quantcast
Viewing all articles
Browse latest Browse all 46

Answer by bsingh for bash/fish command to print absolute path to a file

For directories dirname gets tripped for ../ and returns ./.

nolan6000's function can be modified to fix that:

get_abs_filename() {
  # $1 : relative filename
  if [ -d "${1%/*}" ]; then
    echo "$(cd ${1%/*}; pwd)/${1##*/}"
  fi
}

Viewing all articles
Browse latest Browse all 46

Trending Articles