联盟,交集和FIND命令排除? [英] Union, Intersection and Exclude with the FIND-command?

查看:159
本文介绍了联盟,交集和FIND命令排除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用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。 

问题产生的问题:


  1. find〜/ bin / FilesDvorak /.* -maxdepth
    0 -and〜/ .PAST_RC_files /.*


  2. 请参阅递归查找
    href =https://stackoverflow.com/questions/895724/how-can-i-combine-the -bind / FilesDvorak /.* -maxdepth
    -find-commands>在这里点击

    0和列表


解决方案

是为了。我不认为手册页可以更清晰: 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:

  1. find ~/bin/FilesDvorak/.* -maxdepth 0 -and ~/.PAST_RC_files/.*

  2. Please, consult for recursive find Click here!

  3. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆