当前位置: 技术问答>linux和unix
求助shell编程里的特殊符号的意义
来源: 互联网 发布时间:2016-09-08
本文导语: mv $file ${file/%.txt/.log} 这是一个for循环语句,就是把后缀名为.txt改为.log 不过,我不明白file/%.txt里的/%在这起什么作用?就是它代表什么意思? 在网上都是对/、%的解释,没有解释二者组合的意思。 还望高手讲解讲解。 十分...
mv $file ${file/%.txt/.log}
这是一个for循环语句,就是把后缀名为.txt改为.log
不过,我不明白file/%.txt里的/%在这起什么作用?就是它代表什么意思?
在网上都是对/、%的解释,没有解释二者组合的意思。
还望高手讲解讲解。
十分感谢!
|
${parameter/pattern/string}
The pattern is expanded to produce a pattern just as in filename expansion. Parameter is expanded and the longest match of pattern against its value is replaced with string. If pattern begins with ‘/’, all matches of pattern are replaced with string. Normally only the first match is replaced. If pattern begins with ‘#’, it must match at the beginning of the expanded value of parameter. If pattern begins with ‘%’, it must match at the end of the expanded value of parameter. If string is null, matches of pattern are deleted and the / following pattern may be omitted. If parameter is ‘@’ or ‘*’, the substitution 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 substitution operation is applied to each member of the array in turn, and the expansion is the resultant list.
The pattern is expanded to produce a pattern just as in filename expansion. Parameter is expanded and the longest match of pattern against its value is replaced with string. If pattern begins with ‘/’, all matches of pattern are replaced with string. Normally only the first match is replaced. If pattern begins with ‘#’, it must match at the beginning of the expanded value of parameter. If pattern begins with ‘%’, it must match at the end of the expanded value of parameter. If string is null, matches of pattern are deleted and the / following pattern may be omitted. If parameter is ‘@’ or ‘*’, the substitution 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 substitution operation is applied to each member of the array in turn, and the expansion is the resultant list.
|
http://bbs.chinaunix.net/thread-218853-1-1.html
http://bbs.chinaunix.net/viewthread.php?tid=218853&extra=&page=7#pid1617953
http://bbs.chinaunix.net/viewthread.php?tid=218853&extra=&page=7#pid1617953
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。