shellA调用shellB,如果shellB 里面需要使用路径作为变量,去寻找其它文件.那么要注意,不用pwd,其返回的是系统中用户当前所在位置的路径,也就是shellA的路径,这样就错了.应该用dirname $0,找出当前执行文件的路劲. 场景: 脚本 observerReport.sh 里面调用 mergerReport.sh,observerReport.sh在script/目录, mergerReport.sh在下一级子目录script/merge里, 此时,如果mergerRepo