[20180131]bash變數替換與擷取.txt
[20180131]bash變數替換與擷取.txt
--//bash程式設計經常用到變數替換與擷取,經常記不住,做一些例子說明:
$ a=1a1b1c1d
$ echo $a
1a1b1c1d
$ echo ${a##*1}
d
$ echo ${a#*1}
a1b1c1d
--// ## 最長匹配替換 # 最短匹配替換
$ echo ${a%1*}
1a1b1c
$ echo ${a%%1*}
$ echo ${a%%c*}
1a1b1
--// %% 表示從尾部開始最長匹配替換 % 表示從尾部開始最短匹配替換
$ echo ${a/1/|}
|a1b1c1d
$ echo ${a//1/|}
|a|b|c|d
--// /替換1次 //全域性替換 注意後面沒有斜線.
$ echo -e ${PATH//:/\\n}
/u01/app/oracle/product/11.2.0.4/dbhome_1/jdk/bin
/usr/bin
/u01/app/oracle/product/11.2.0.4/dbhome_1/jdk/bin
/usr/bin
/usr/kerberos/bin
/usr/local/bin
/bin
/usr/bin
/usr/NX/bin
/home/oracle/bin
/u01/app/oracle/product/11.2.0.4/dbhome_1/bin
/home/oracle/anysql
/usr/NX/bin
/home/oracle/bin
/u01/app/oracle/product/11.2.0.4/dbhome_1/bin
/home/oracle/anysql
--//實際上bash還有許多功能,這些實際平時不用,實在記不住...
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2150690/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Golang 字串分割,替換和擷取 strings.SplitGolang字串
- bash 引數替換中的模式匹配模式
- python函式教程:Python 字串操作(string替換、擷取等)Python函式字串
- 如何用在bash中擷取部分系統引數?
- [20200217]bash顯示path環境變數.txt變數
- [20221111]bash eval設定變數問題.txt變數
- 教你如何替換@PathVariable中的變數變數
- Excel 多個變數替換 實際值Excel變數
- [20180413]bash 位置引數.txt
- [20190126]從sqlplus執行結果返回bash shell變數.txtSQL變數
- HTML 替換元素與非替換元素HTML
- shell Bash變數變數
- [20180926]bash與分號.txt
- Asp.Net MVC路由引數獲取、替換ASP.NETMVC路由
- Bash變數和引數變數
- Stata-將變數名稱替換成標籤變數
- C#用正規表示式高效替換變數C#變數
- EOF 如何防止多行寫入檔案變數替換變數
- 定積分之換元積分法公式(或稱變數替換法)公式變數
- [20180930]in list與繫結變數.txt變數
- [20180912]PLSLQ與繫結變數.txt變數
- [20180930]in list與繫結變數個數.txt變數
- [20210120]in list與繫結變數個數.txt變數
- [20231123]函式與bash shell呼叫.txt函式
- 詳解Linux bash變數Linux變數
- 正規表示式中使用變數擷取某字串前後內容變數字串
- Lumen 替換 world 裡面變數並匯出 PDF 圖片變數
- Lumen 替換 Word 裡面變數並匯出 PDF 圖片變數
- [20220105]sqlplus &1替換最大支援239個字元.txtSQL字元
- shell程式設計–bash變數程式設計變數
- 字串擷取字串
- js擷取JS
- 每天三分半鐘搞定linux基礎知識(19) echo命令實現字串的擷取和替換Linux字串
- [20181203]bash here $.txt
- [20180930]bash shell &.txt
- [20210318]bash test (( )) [[ ]].txt
- [20200326]繫結變數抓取與NULL值.txt變數Null
- [20220414]toad與繫結變數peek.txt變數
- Linux中bash shell環境變數Linux變數