首页 > 系统服务 > 详细

Get Script Path in Shell

时间:2016-11-12 18:58:12      阅读:169      评论:0      收藏:0      [点我收藏+]

#!/usr/bin/bash

dir_old=$(pwd)
absolute_script_path=$(cd $(dirname $0) && pwd)
relative_script_path=$(dirname $0)
wrong_absolute_script_path=$dir_old/$relative_script_path

echo "Current PATH: $dir_old"
echo "absolute_script_path is: $absolute_script_path"
echo "relative_script_path is: $relative_script_path"
echo "This path might be wrong: $wrong_absolute_script_path"

# Fail if use absolute path to invoke script
cd $wrong_absolute_script_path && pwd

Get Script Path in Shell

原文:http://www.cnblogs.com/xiaochou/p/Get_Script_Path_in_Shell.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!