找到x长度或小于x长度的php文件

时间:2014-08-14 14:52:03

标签: find

我想找到3个字符长或小于它的php文件。例如..php,a.php,cc.php,abc.php等我知道如何通过以下命令找到x长度的文件。例如,如果我想找到3个字符长的php文件并将所有结果转储到文件中我会做

# find . -type f -name "???.php" >> results.txt

我只需要一点调整。

2 个答案:

答案 0 :(得分:1)

globs应该足够好

find -type f \( -name "?.php" -o -name "??.php" -o -name "???.php" \)  >> results.txt

或者如果你想要正则表达式

find -type f -regextype 'posix-basic' -regex '.*/[^/]\{1,3\}\.php$' >> results.txt

答案 1 :(得分:0)

也许这就是你想要的?

find . -name "*.php" |grep "/.\{1,3\}\.php" >> results.txt