本教程操作環境:linux7.3系統、Dell G3電腦。
創建文件
vi test.txt# 按i切換insert模式# 輸入文本#!/bin/bashecho "Hello world!!!"echo $$ # 打印當前進程idecho $test
執行(運行)文件的方式
(相關資料圖)
1、 使用source執行腳本
test=100source test.txt
輸出:
Hello world!!!37790100
使用的為當前bash
2、 使用.執行腳本
. test.txt Hello world!!!37790100
使用的為當前bash
3、 使用bash執行腳本
bash test.txt Hello world!!!47733
進程id更新了,且未獲取到變量test的值,因為啟動了子進程的bash執行腳本。
4、 使用./file執行腳本
注意:此種方式首先得給腳本添加執行權限 chmod +x test.txt
./test.txt Hello world!!!47758
進程id更新了,且未獲取到變量test的值,因為啟動了子進程的bash執行腳本。
推薦學習:Linux視頻教程
以上就是linux運行文件命令有哪些的詳細內容,更多請關注php中文網其它相關文章!
關鍵詞: linux