【发布时间】:2018-08-17 10:17:54
【问题描述】:
您可能认为我已经在某个地方找到了答案,但我正在努力做到这一点。我想查找一些名称类似于
的日志文件myfile_3.log
但是我只想找到数字在一定范围内的那些。我试过这样的事情:
find <path> -name myfile_{0..67}.log #error: find: paths must precede expression
find <path> -name myfile_[0-67].log #only return 0-7, not 67
find <path> -name myfile_[0,67].log #only returns 0,6,7
find <path> -name myfile_*([0,67]).log # returns only 0,6,7,60,66,67,70,76,77
还有其他想法吗?
【问题讨论】:
-
不能用正则表达式表示范围。最好使用 find 来获取带有数字的文件,并使用另一个执行范围检查的工具(如 awk)过滤输出。