如何对查找结果进行排序,以使以一组模式之一开头的路径排在最后
我有一个 find 命令,我想对其进行排序,以便某些目录的条目最后排序。原因是这个列表要传递给 etags 以创建标签表,并且我希望某些第三方工具目录位于我主动编辑的所有代码之后。
有人可以建议一种简单的方法来对列表进行排序作为对我的 makefile 规则的更改吗?以下是当前规则:
tags:
rm -f ../TAGS
find .. \( -not -regex '.*include/.*' \) \
-a \( -name '*.h' -o -name '*.hh' -o -name '*.y' \
-o -name '*.l' -o -name '*.cc' -o -name '*.cpp' \
-o -name '*.c' -o -name '*.inl' \) \
| xargs etags -o ../TAGS --append
例如,以“../flexlm/”或“../src/librsync”开头的条目应位于与这些模式之一不匹配的条目之后。
I have a find command that I would like to sort such that entries for certain directories are sorted last. The reason is that this list is to be passed to etags to create a tags table and I would like certain third-party tool directories to be after all the code I actively edit.
Can someone suggest a good easy way in to sort the list as a change to my makefile rule? Here is the current rule:
tags:
rm -f ../TAGS
find .. \( -not -regex '.*include/.*' \) \
-a \( -name '*.h' -o -name '*.hh' -o -name '*.y' \
-o -name '*.l' -o -name '*.cc' -o -name '*.cpp' \
-o -name '*.c' -o -name '*.inl' \) \
| xargs etags -o ../TAGS --append
For example, entries that begin "../flexlm/" or "../src/librsync" should come after entries that don't match one of these patterns.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将多个
find
命令放入大括号块中,并将其通过管道传输到xargs
中:Put multiple
find
commands in a brace block and pipe that intoxargs
:假设您有能力运行多个查找查询,并且您的项目设置为可以使用一个查询找到您自己的源文件,并使用其他查询找到任何库……
那就是我会做什么。
Well assuming you can afford to run multiple find queries and you have your project set up in such a way that it is possible to find your own source files with one query and any libraries with other queries...
... That'd be what I'd do.
通过结合上述答案并进行调整,以下是对我有用的方法:
Here is what worked for me by combining the above answers and tweaking them: