1、 $0 

#!/bin/sh
echo $0 

 

2、shFile=$(readlink -f $0)

 

#!/bin/sh
shFile=$(readlink -f $0)
shDir=$(dirname ${shFile})
echo $shFile

[dongjunjie@test]$ ./test.sh
/data/dongjunjie/test/test.sh

$0的方式,如果执行脚本的时候是按照相对路径执行的,$0 也是一个相对位置

但是这种方式缺可以绝对路径的方式展现

相关文章:

  • 2022-02-06
  • 2022-02-21
  • 2022-01-15
  • 2021-07-03
  • 2021-05-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-01-10
  • 2021-07-10
  • 2022-12-23
  • 2021-11-30
相关资源
相似解决方案