Answers for "how to source bash script path bash"

0

how to source bash script path bash

#!/bin/bash NOT #!/bin/sh
#### script begin /home/aaa/scripts/script.sh###
sdir=$(dirname "$0") #script directory

cdir=$(pwd) #path to currunt working directory 

edir=$(dirname "0") # bit tricky, script executed dir. 

SCRIPT=`realpath $0`
SCRIPTPATH=`dirname $SCRIPT` 

echo $sdir
echo $cdir
echo $edir

echo $SCRIPTPATH

script path /home/aaa/scritps/script.sh ###
$bash ./scritps/test.sh
#####outputs ########
scritps #echo $sdir
/home/aaa/ #echo $cdir
. # echo $edir 
/home/aaa/scripts/script.sh  # echo $SCRIPT
/home/aaa/scritps #echo $SCRIPTPATH

 # use this to source your script path
SCRIPT=`realpath $0`
SCRIPTPATH=`dirname $SCRIPT`
Posted by: Guest on July-30-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language