使用 FIND 命令联合、交叉和排除? [英] Union, Intersection and Exclude with the FIND-command?
问题描述
我需要使用 find-command 管理列表.假设列表在非不同列表中具有随机名称(即它们的交集不是空集).我该怎么做:
I need to manage lists with find-command. Suppose the lists have random names in non-distinct lists (ie their intersection is not empty set). How can I do:
AB
在列表 A 中查找除了列表 B 中的文件之外的文件
find files in the list A except the files in the list B
A路口B
查找列表 A 和 B 共有的文件
find files common to the lists A and B
请在这里查阅.
联合 B
查找两个列表中的所有文件
find all files in the two lists
示例
$ find . | awk -F"/" '{ print $2 }'
.zcompdump
.zshrc
.bashrc
.emacs
$ find ~/bin/FilesDvorak/.* -maxdepth 0 | awk -F"/" '{ print $6 }'
.bashrc
.emacs
.gdbinit
.git
我想要:
AB:
.zcompdump
.zshrc
A 路口 B:
.bashrc
.emacs
A 联合 B:
.zcompdump
.zshrc
.bashrc
.emacs
.bashrc
.emacs
.gdbinit
.git
十字路口的尝试
当我将输出保存到单独的列表时,我无法理解为什么该命令不采用常见的东西,即上面的交集:
When I save the outputs to separate lists, I cannot understand why the command does not take the common things, ie the above intersection:
find -f all_files -and -f right_files .
问题中出现的问题:
找到 ~/bin/FilesDvorak/.* -maxdepth0 - 和 ~/.PAST_RC_files/.*
find ~/bin/FilesDvorak/.* -maxdepth 0 -and ~/.PAST_RC_files/.*
请咨询递归查找<一个href="https://stackoverflow.com/questions/895724/how-can-i-combine-the-find-commands">点击在这里!
找到 ~/bin/FilesDvorak/.* -maxdepth0 - 并列出
find ~/bin/FilesDvorak/.* -maxdepth 0 -and list
推荐答案
说真的,这就是 comm(1) 的用途.我认为手册页不会更清晰:http://linux.die.net/man/1/comm
Seriously, this is what comm(1) is for. I don't think the man page could be much clearer: http://linux.die.net/man/1/comm
这篇关于使用 FIND 命令联合、交叉和排除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!