get current script name and absolute paths


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  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"

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.