当前位置:网站首页>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
边栏推荐
- Log4j2 cross thread print traceid
- journal
- Process management command
- Stanford machine learning course summary
- Visualization of residential house prices
- C language to achieve 2048 small game direction merging logic
- Test post and login function
- Install pyshp Library
- Calculation of fishing net road density
- 硬核解析Promise对象(这七个必会的常用API和七个关键问题你都了解吗?)
猜你喜欢

ArcGIS table to excel exceeds the upper limit, conversion failed

Dock installation redis

Robocode Tutorial 4 - robocode's game physics

MATLAB从入门到精通(二)

Nodejs安装

Data stream encryption and decryption of C

String function in MySQL

Matlab tips (6) comparison of seven filtering methods

硬核解析Promise對象(這七個必會的常用API和七個關鍵問題你都了解嗎?)

C language loop structure program
随机推荐
Install pyshp Library
Queue solving Joseph problem
Nodejs installation
I / O multiplexing and its related details
深度学习经典网络解析目标检测篇(一):R-CNN
JD-FreeFuck 京東薅羊毛控制面板 後臺命令執行漏洞
Clion installation tutorial
Differences between SSD hard disk SATA interface and m.2 interface (detailed summary)
Multi thread crawling Marco Polo network supplier data
Pyppeter crawler
Linux installs MySQL in RPM (super simple)
14 py games source code share the second bullet
Serial port debugging tools cutecom and minicom
Robocode tutorial 5 - enemy class
Excel opens large CSV format data
【ACM】509. Fibonacci number (DP Trilogy)
STM32学习记录0008——GPIO那些事1
【ACM】70. 爬楼梯
word frequency count
Data stream encryption and decryption of C