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