我正在尝试执行此命令
find /home/scratch/test_cases/deleted/2nmW1wDfb5/ -iregex '.*/moodys_munis_full_refresh_flat_file_\d+.zip' -type f
找不到任何文件,但是当我执行ls
时文件就在那里ls /home/scratch/test_cases/deleted/2nmW1wDfb5/moodys_munis_full_refresh_flat_file_2.zip
结果是
/home/scratch/test_cases/deleted/2nmW1wDfb5/moodys_munis_full_refresh_flat_file_2.zip
答案 0 :(得分:1)
尝试:
find ... -iregex '.*[0-9]+.zip' -type f
代替。或者运行
find -regextype --help
find: Unknown regular expression type '--help'; valid types are 'findutils-default', 'awk', 'egrep', 'ed', 'emacs', 'gnu-awk', 'grep', 'posix-awk', 'posix-basic', 'posix-egrep', 'posix-extended', 'posix-minimal-basic', 'sed'.
获取系统中已知-regextypes的列表,然后尝试
find ... -regextype sed -iregex '.*[0-9]+.zip' -type f
以及其他选项,如果您不知道哪种风格代表什么。
在我的系统上,\ d不适用于任何选项:
for rt in "findutils-default" "awk" "egrep" "ed" "emacs" "gnu-awk" "grep" "posix-awk" "posix-basic" "posix-egrep" "posix-extended" "posix-minimal-basic" "sed"
do
echo -n $rt" "
find . -type f -regextype $rt -iregex '.*ro.*2\d+.scala'
echo
done
findutils-default
awk
egrep
ed
emacs
gnu-awk
grep
posix-awk
posix-basic
posix-egrep
posix-extended
posix-minimal-basic
sed
虽然大约50%的矩形括号被理解:
for rt in "findutils-default" "awk" "egrep" "ed" "emacs" "gnu-awk" "grep" "posix-awk" "posix-basic" "posix-egrep" "posix-extended" "posix-minimal-basic" "sed"
do
echo -n $rt" "
find . -type f -regextype $rt -iregex '.*ro.*2[0-9]+.scala'
echo
done
findutils-default ./rot1-25.scala
awk ./rot1-25.scala
egrep ./rot1-25.scala
ed
emacs ./rot1-25.scala
gnu-awk ./rot1-25.scala
grep
posix-awk ./rot1-25.scala
posix-basic
posix-egrep ./rot1-25.scala
posix-extended ./rot1-25.scala
posix-minimal-basic
sed