日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

linux script $,linux – 这在shell脚本中是什么意思SCRIPTNAME =“${0 ## * /}”?

發(fā)布時(shí)間:2024/7/19 linux 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux script $,linux – 这在shell脚本中是什么意思SCRIPTNAME =“${0 ## * /}”? 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

此代碼來(lái)自apache2服務(wù)啟動(dòng)腳本.

這是什么意思?

SCRIPTNAME="${0##*/}"

解決方法:

它找到正在運(yùn)行的腳本的名稱,刪除其目錄.例如,如果腳本是/etc/init.d/httpd,那么這將設(shè)置SCRIPTNAME = httpd.

$0或${0}是正在執(zhí)行的腳本的名稱. ##運(yùn)算符用于刪除與模式* /匹配的任何前導(dǎo)字符串. *是通配符,因此* /表示“任何字符串后跟正斜杠”.

這樣做的效果是從$0中刪除任何前導(dǎo)目錄名稱,只留下腳本的名稱.

來(lái)自man bash:

${parameter#word}

${parameter##word}

The word is expanded to produce a pattern just as in pathname expansion. If the pattern

matches the beginning of the value of parameter, then the result of the expansion is the

expanded value of parameter with the shortest matching pattern (the “#” case) or the longest

matching pattern (the “##” case) deleted. If parameter is @ or *, the pattern removal operation is applied to each positional parameter in turn, and the expansion is the resultant

list. If parameter is an array variable subscripted with @ or *, the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list.

標(biāo)簽:linux,sh

來(lái)源: https://codeday.me/bug/20190902/1790603.html

總結(jié)

以上是生活随笔為你收集整理的linux script $,linux – 这在shell脚本中是什么意思SCRIPTNAME =“${0 ## * /}”?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。