当前位置:网站首页>In shell programming, the shell file with relative path is referenced
In shell programming, the shell file with relative path is referenced
2022-04-23 18:14:00 【The hunter is eating meat】
There are two in the same directory shell file : xxutil.sh、main.sh.
Under normal circumstances main.sh Use in xxutil.sh The contents are as follows :
main.sh :
source ./xxutil.sh
# ...
# ...
perform command sh main.sh
, normal , No problem .
however , If In other directories , Use absolute commands perform main.sh
when , Will throw out : Can't find xxutil.sh Errors in documents .
The solution is as follows :
DIRNAME=$0
if [ "${DIRNAME:0:1}" = "/" ];then
CURDIR=`dirname $DIRNAME`
else
CURDIR="`pwd`"/"`dirname $DIRNAME`"
fi
#echo $CURDIR
source $CURDIR/xxutil.sh
版权声明
本文为[The hunter is eating meat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210611118177.html
边栏推荐
- Rust: a simple example of TCP server and client
- Selenium + phantom JS crack sliding verification 2
- [UDS unified diagnostic service] IV. typical diagnostic service (6) - input / output control unit (0x2F)
- Qt读写XML文件(含源码+注释)
- Docker 安裝 Redis
- NVIDIA Jetson: GStreamer and openmax (GST OMX) plug-ins
- Rust: the output information of println is displayed during the unit test
- Closure type of rust (difference between FN, fnmut and fnone)
- Matlab tips (6) comparison of seven filtering methods
- Cygwin64 right click to add menu, and open cygwin64 here
猜你喜欢
[UDS unified diagnostic service] v. diagnostic application example: Flash bootloader
JD-FreeFuck 京东薅羊毛控制面板 后台命令执行漏洞
MATLAB小技巧(6)七种滤波方法比较
Robocode tutorial 8 - advanced robot
Re expression régulière
【ACM】455. Distribute Biscuits (1. Give priority to big biscuits to big appetite; 2. Traverse two arrays with only one for loop (use subscript index -- to traverse another array))
【ACM】376. Swing sequence
C medium? This form of
SSD硬盘SATA接口和M.2接口区别(详细)总结
深度学习经典网络解析目标检测篇(一):R-CNN
随机推荐
Differences between SSD hard disk SATA interface and m.2 interface (detailed summary)
positioner
Secure credit
Batch export ArcGIS attribute table
Selenium + phantom JS crack sliding verification 2
Visualization of residential house prices
Qt读写XML文件(含源码+注释)
STM32学习记录0008——GPIO那些事1
【ACM】509. 斐波那契数(dp五部曲)
【ACM】376. 摆动序列
Format problems encountered in word typesetting
Docker 安装 Redis
NVIDIA Jetson: GStreamer and openmax (GST OMX) plug-ins
Dynamically add default fusing rules to feign client based on sentinel + Nacos
JD-FreeFuck 京東薅羊毛控制面板 後臺命令執行漏洞
Random number generation of C #
Nodejs installation
Selenium + webdriver + chrome realize Baidu to search for pictures
【ACM】376. Swing sequence
【ACM】455. 分发饼干(1. 大饼干优先喂给大胃口;2. 遍历两个数组可以只用一个for循环(用下标索引--来遍历另一个数组))