2
有沒有一種很好的方法來解釋下面的工作方式?
~$ echo $test
en.to.tre
~$ echo ${test}
en.to.tre
~$ echo ${test%.*}
en.to
~$ echo ${test%%.*}
en
~$ echo ${test#*.}
to.tre
~$ echo ${test##*.}
tre
我特別不明白爲什麼.
和*
有刪除/左/右保持時被交換。
你可以選擇這個:[wooledge.org - 如何使用參數擴展?我怎樣才能得到子字符串?我怎樣才能得到沒有擴展名的文件,或只得到一個文件的擴展名?](http://mywiki.wooledge.org/BashFAQ/073) – fedorqui
也許你也可以查看:http://tldp.org/LDP/abs /html/refcards.html#AEN22664 – devnull