cut的问题
时间:2011-10-12
来源:互联网
我想通过 find 查找目录中所有以 .o 结尾的文件和一个名为 main 的文件,这个 find 应该如何写?我写下边的表达式只能找到 .o 但无法找到那个 main。
find . -regex "\(.*\.\(o\)\)\|\(main\)" -ls
请各位不吝赐教。
find . -regex "\(.*\.\(o\)\)\|\(main\)" -ls
请各位不吝赐教。
作者: alober 发布时间: 2011-10-12
man find 可得:
所以你的main要匹配全路径, 也就是你find -type f -name main的输出,一字不差.
引用:
-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 `b.*r3'.
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 `b.*r3'.
所以你的main要匹配全路径, 也就是你find -type f -name main的输出,一字不差.
代码:
find . -type f -regex '.*\.o$\|.*/main$'
作者: Methuselar 发布时间: 2011-10-12
为什么不用
代码:
find -type f \( -name main -o -name '*.o' \)
? 作者: lilydjwg 发布时间: 2011-10-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28