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