Quantcast
Channel: How to obtain the absolute path of a file via Shell (BASH/ZSH/SH)? - Stack Overflow
Viewing all articles
Browse latest Browse all 46

Answer by bsingh for How to obtain the absolute path of a file via Shell (BASH/ZSH/SH)?

$
0
0

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



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>