Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ### Bash-Script: dir and script name ###
- ## Setup ##
- if [ ! -f "/tmp/src dir/test.sh" ];
- then
- # copy pased to terminal to run it instant ;-)
- mkdir -p "/tmp/src dir/other"
- cd "/tmp/src dir/"
- wget -O test.sh https://pastebin.com/raw/J8KjxrPF
- sed -i 's/\r//g' test.sh
- chmod 700 test.sh
- cd other
- ../test.sh
- # end copy pased
- fi
- ## The script ##
- echo "Sample: \"/tmp/src dir/test.sh\" called by \"/tmp/src dir/other\""
- echo "See script @ Setup"
- echo
- echo Script-Dir : `dirname "$(realpath $0)"`
- echo Script-Dir : $( cd ${0%/*} && pwd -P )
- echo Script-Dir : $(dirname "$(readlink -f "$0")")
- echo
- echo Script-Name : `basename "$(realpath $0)"`
- echo Script-Name : `basename $0`
- echo
- echo Script-Dir-Relative : `dirname "$BASH_SOURCE"`
- echo Script-Dir-Relative : `dirname $0`
- echo
- echo Calling-Dir : `pwd`
- ## The output: ##
- # Script-Dir : /tmp/src dir
- # Script-Dir : /tmp/src dir
- # Script-Dir : /tmp/src dir
- # Script-Name : test.sh
- # Script-Name : test.sh
- # Script-Dir-Relative : ..
- # Script-Dir-Relative : ..
- # Calling-Dir : /tmp/src dir/other
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement