我正在尝试使用 find 来为我的 sh 脚本获取目标文件
PREVIOUS_FILE="FX00.txt"
var=$(find /usr1/fida -regextype posix-extended -regex "$PREVIOUS_FILE\.(ok|false)")
当执行结束时,var 为空。
我要找
FX00.txt.ok
如果我在普通 shell 中执行它,它就可以工作。有什么建议吗?
最好的问候!
最佳答案
根据find
的手册:
-regex pattern
File name matches regular expression pattern. This is a match on the whole path, not a search. For example, to match a file named
./fubar3
, you can use the regular expression.*bar.
or.*b.*3
, but notf.*r3
.
关于linux - 在正则表达式中使用带有变量的查找,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43675291/