原文:shell脚本中执行source命令不生效的解决办法

一个shell脚本文件中有一个source命令,使用bash a.sh命令执行后source命令进行验证没有生效。 这是因为在shell脚本中执行source会看到效果,但是shell脚本执行完后再次验证就没看到效果。 此时可以换这种方式执行shell脚本命令:source a.sh ...

2021-04-13 13:23 0 1105 推荐指数:

查看详情

source命令shell脚本执行生效的原因

最近发现,把我原来编译安装MySQL的命令写到脚本里,然后执行source命令执行总是不生效。 查了下资料,算是知道了原因,在此记录一下。 使用 bash 脚本名 方式来执行脚本,这种方式会启动一个子shell,在子shell执行脚本里面的语句,该子shell继承父shell的环境变量 ...

Sat Aug 22 02:55:00 CST 2020 0 2145
linux下shell脚本执行方法及exec和source命令

exec和source都属于bash内部命令(builtins commands),在bash下输入man exec或man source可以查看所有的内部命令信息。 bash shell命令分为两类:外部命令和内部命令。外部命令是通过系统调用或独立的程序实现的,如sed、awk等等。内部命令 ...

Tue Apr 29 01:50:00 CST 2014 0 2860
shell脚本中使用nohup执行命令生效

1 例如 !#/bin/bash nohup echo "hello world"    2 解决办法 加上 source /etc/profile 就好了 !#/bin/bash source /etc/profile nohup echo "hello ...

Sat Jul 13 06:43:00 CST 2019 0 4198
ubuntu shell 提示 source : not found 原因及解决办法

现象: shell脚本source aaa.sh时提示 source: not found 原因: ls -l `which sh` 提示/bin/sh -> dash 这说明是用dash来进行解析的。 改回方法: 命令执行:sudo dpkg-reconfigure ...

Fri Apr 30 01:14:00 CST 2021 0 212
source command not found in sh shell解决办法

在Ubuntu系统执行脚本的时候突然出现错误“source command not found in sh shell” 这个其实在Ubuntu 当中 执行脚本默认的使用的是dash,而非bash 通过命令 我们发现, 脚本默认使用的sh其实对应的是dash ...

Sun Dec 25 06:09:00 CST 2016 0 4092
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM