联盟,交集和FIND命令排除? [英] Union, Intersection and Exclude with the FIND-command?
问题描述
A \ B
在列表A中查找文件,但列表B中的文件除外b
交叉点B
查找列表A和B共有的文件
请参阅此处。
工会B
找到所有文件在这两个列表中
示例
$ find。 | awk -F/'{print $ 2}'
.zcompdump
.zshrc
.bashrc
.emacs
$ find 〜/ bin / FilesDvorak /.* -maxdepth 0 | awk -F/'{print $ 6}'
.bashrc
.emacs
.gdbinit
.git
我想:
A \ B :
.zcompdump
.zshrc
B路口:
.bashrc
.emacs
联盟B :
.zcompdump
.zshrc
.bashrc
.emacs
.bashrc
.emacs
.gdbinit
.git
尝试交叉路口
当我将输出保存到单独的列表中时,我无法理解为什么命令不采取常见的事情,即上面的交叉点:
find -f all_files -and -f right_files。
问题产生的问题:
find〜/ bin / FilesDvorak /.* -maxdepth
0 -and〜/ .PAST_RC_files /.*
请参阅递归查找
0和列表
href =https://stackoverflow.com/questions/895724/how-can-i-combine-the -bind / FilesDvorak /.* -maxdepth
-find-commands>在这里点击
!
解决方案是为了。我不认为手册页可以更清晰: http://linux.die.net / man / 1 / comm
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:
A \ B
find files in the list A except the files in the list B
A intersection B
find files common to the lists A and B
Please, consult here.
A union B
find all files in the two lists
EXAMPLES
$ find . | awk -F"/" '{ print $2 }' .zcompdump .zshrc .bashrc .emacs $ find ~/bin/FilesDvorak/.* -maxdepth 0 | awk -F"/" '{ print $6 }' .bashrc .emacs .gdbinit .git
I want:
A \ B:
.zcompdump .zshrc
A Intersection B:
.bashrc .emacs
A Union B:
.zcompdump .zshrc .bashrc .emacs .bashrc .emacs .gdbinit .git
A try for the Intersection
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 .
Questions emerged from the question:
find ~/bin/FilesDvorak/.* -maxdepth 0 -and ~/.PAST_RC_files/.*
Please, consult for recursive find Click here!
find ~/bin/FilesDvorak/.* -maxdepth 0 -and list
解决方案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屋!