当前位置: 技术问答>linux和unix
简单脚本问题
来源: 互联网 发布时间:2016-05-31
本文导语: prog="$0" newProg=`/bin/ls -ld "${prog}"` newProg=`expr "${newProg}" : ".* -> (.*)$"` 请问第三行是什么意思? | expr abc : 'a(.)c' => b 就是从 ${newProg} 截取匹配的字符串部分 这里的用意是获得符号链...
prog="$0"
newProg=`/bin/ls -ld "${prog}"`
newProg=`expr "${newProg}" : ".* -> (.*)$"`
请问第三行是什么意思?
newProg=`/bin/ls -ld "${prog}"`
newProg=`expr "${newProg}" : ".* -> (.*)$"`
请问第三行是什么意思?
|
expr abc : 'a(.)c' => b
就是从 ${newProg} 截取匹配的字符串部分
这里的用意是获得符号链接指向的目标
就是从 ${newProg} 截取匹配的字符串部分
这里的用意是获得符号链接指向的目标
`STRING : REGEX'
Perform pattern matching.
If the match succeeds and REGEX uses `(' and `)',
the `:' expression returns the part of STRING that
matched the subexpression; otherwise, it returns
the number of characters matched.
|
第三行属于模式匹配
ls 查找的文件中 抽取软连接文件
ls 查找的文件中 抽取软连接文件