Linux bash know the script path which includes library script -


this question has answer here:

i have library script named , script b, c includes

. ../../../a  

the problem how can know time run ./b.sh or ./c.sh, example:

if(run ./b.sh)    echo "b (file path) calling" else    echo "c (file path) calling" 

you can use $0 determine command executed:

a.sh:

echo $0 

b.sh:

. ./a.sh 

when run:

$ sh b.sh  b.sh $ sh a.sh  a.sh 

it give command executed, not arguments:

$ sh b.sh 1 2 3 b.sh 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -