Digital Marketing

How to get the self script file name in a Bash script?

[ec2-user@dockers ~]$ cat ~/test.sh
echo $BASH_SOURCE
# get file name only without path
echo $(basename $BASH_SOURCE)
[ec2-user@dockers ~]$ bash ~/test.sh
/home/ec2-user/test.sh
test.sh
[ec2-user@dockers ~]$ ~/test.sh
/home/ec2-user/test.sh
test.sh
[ec2-user@dockers ~]$ ./test.sh
./test.sh
test.sh
[ec2-user@dockers ~]$

Comments

Popular posts from this blog

How to delete / clear queue of PowerMTA