欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

linux執(zhí)行shell腳本的四種方式-創(chuàng)新互聯(lián)

這篇文章主要為大家詳細介紹了linux執(zhí)行shell腳本的四種方式,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下。

創(chuàng)新互聯(lián)公司是一家成都做網(wǎng)站、成都網(wǎng)站設(shè)計、成都外貿(mào)網(wǎng)站建設(shè),提供網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,網(wǎng)站制作,建網(wǎng)站,按需定制設(shè)計,網(wǎng)站開發(fā)公司,從2013年成立是互聯(lián)行業(yè)建設(shè)者,服務(wù)者。以提升客戶品牌價值為核心業(yè)務(wù),全程參與項目的網(wǎng)站策劃設(shè)計制作,前端開發(fā),后臺程序制作以及后期項目運營并提出專業(yè)建議和思路。

linux執(zhí)行shell腳本的四種方式

Linux中shell腳本的執(zhí)行通常有4種方式,分別為工作目錄執(zhí)行,絕對路徑執(zhí)行,sh執(zhí)行,shell環(huán)境執(zhí)行。

首先,看下我們的腳本內(nèi)容

[tan@tan scripts]$ ll
total 4
-rw-rw-r--. 1 tan tan 68 May 8 23:18 test.sh
[tan@tan scripts]$ cat test.sh 
#!/usr/bin/bash
 
/usr/bin/python <<-EOF
print "Hello Shell"
    EOF

1、工作目錄執(zhí)行

工作目錄執(zhí)行,指的是執(zhí)行腳本時,先進入到腳本所在的目錄(此時,稱為工作目錄),然后使用 ./腳本方式執(zhí)行

[tan@tan scripts]$ ./test.sh
-bash: ./test.sh: Permission denied
[tan@tan scripts]$ chmod 764 test.sh
[tan@tan scripts]$ ./test.sh
Hello Shell

報了權(quán)限錯誤,這里需要賦權(quán),使用chmod 764 test.sh 賦權(quán)后就可以正常執(zhí)行了。

2、絕對路徑執(zhí)行

絕對路徑中執(zhí)行,指的是直接從根目錄/到腳本目錄的絕對路徑

[tan@tan scripts]$ pwd
/home/tan/scripts
[tan@tan scripts]$ `pwd`/test.sh 
Hello Shell
[tan@tan scripts]$ /home/tan/scripts/test.sh 
Hello Shell

3、sh執(zhí)行

sh執(zhí)行,指的是用腳本對應(yīng)的sh或bash來接著腳本執(zhí)行

[tan@tan scripts]$ sh test.sh 
Hello Shell
[tan@tan scripts]$ bash test.sh 
Hello Shell

4、shell環(huán)境執(zhí)行

shell環(huán)境執(zhí)行,指的是在當(dāng)前的shell環(huán)境中執(zhí)行,可以使用 . 接腳本 或 source 接腳本

[tan@tan scripts]$ . test.sh 
Hello Shell
[tan@tan scripts]$ source test.sh 
Hello Shell

以上就是linux執(zhí)行shell腳本的四種方式的詳細內(nèi)容了,看完之后是否有所收獲呢?如果想了解更多相關(guān)內(nèi)容,歡迎來創(chuàng)新互聯(lián)行業(yè)資訊!

當(dāng)前名稱:linux執(zhí)行shell腳本的四種方式-創(chuàng)新互聯(lián)
文章源于:http://chinadenli.net/article32/icgsc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、虛擬主機動態(tài)網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)網(wǎng)站維護服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計