原文: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