linux - 在正则表达式中使用带有变量的查找

标签 linux bash

我正在尝试使用 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 not f.*r3.

关于linux - 在正则表达式中使用带有变量的查找,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43675291/

相关文章:

python - 从 python 打开终端应用程序并在其中运行自定义脚本

linux - 在服务器端使用 bash 代替 PHP/Perl 或 Java

linux - 使用 bash 历史记录获取先前的命令,复制它,然后 'run' 它但命令注释

linux - 是否可以在 gnuplot 中绘制正态概率分布

c - 在父进程终止时向子进程树发出 SIGKILL

linux - 如何将python脚本放入jetson nano启动中?

linux - 如何从 Windows 机器检查 Linux 文件 (.so) 是 32 位还是 64 位

c - 编写一个函数,显示三个不同数字的所有不同组合

Linux Bash 脚本 : Delete files in folder, 但排除特定文件

c - Linux Socket 重新读取旧数据