xvno / blog

个人博客, 不定期发布技术笔记和个人随笔.
0 stars 0 forks source link

Shell: Tips #152

Open xvno opened 3 years ago

xvno commented 3 years ago

Refs

xvno commented 3 years ago

在 .sh 文件中获取该文件所在位置

通常用在以该 .sh 文件所在文件夹为工作目录的某些操作中

# file_dir=`cd $(dirname $0) && pwd`
file_path=$(dirname $0)
file_dir=$(cd $file_path && pwd)

# e.g.
cat $file_dir/mysql.env