Posted By

aresnick on 11/05/08


Tagged

filename current-name absolute-path


Versions (?)

get current script name and absolute paths


 / Published in: Bash
 

URL: http://www.jtanium.com/blog/?p=57

  1. #!/usr/bin/env bash
  2.  
  3. echo " \\$0: $0"
  4.  
  5. _my_name=`basename $0`
  6. if [ "`echo $0 | cut -c1`" = "/" ]; then
  7. _my_path=`dirname $0`
  8. else
  9. _my_path=`pwd`/`echo $0 | sed -e s/$_my_name//`
  10. fi
  11.  
  12. echo " Filename: $_my_name"
  13. echo "Absolute path: $_my_path"

Report this snippet  

You need to login to post a comment.