How does the AND operator in FIND command work?
My last question is expanded, so let's analyze things separately.
AND-operater, intersection?
Here's an example:
$ find . | awk -F"/" '{ print $2 }'
.zcompdump
.zshrc
.zshrc_copy
.zshrc_somequy
.bashrc
.emacs
$ find ~/bin/FilesDvorak/.* -maxdepth 0 | awk -F"/" '{ print $6 }'
.bashrc
.emacs
.gdbinit
.git
.profile
When I save the outputs to separate lists, I can't figure out why the command doesn't accept general things:
find -f all_files -and -f right_files .
I only want:
.bashrc
.emacs
a source to share
To expand on Dave's answer a bit:
It seems you need the intersection of the two find commands. Find does not do a set of manipulations. Find the traverses down (or up, depending on how you look at it) a set of paths and apply an expression for each element it encounters. The default action is to print the path of the found items that evaluate to true for expressions. (I believe some older versions of find required you to explicitly add the -print expression.) It does not match the results. You can use tools like diff, sdiff, comm to analyze intersections .
I am assuming that you are trying to find items with the same name in two separate directories, not sub-directories.
Assuming bash, you can do something like
comm -12 <(find . -maxdepth 1 | sort) <(cd ~/bin/FilesDvorak/; find . -maxdepth 1 | sort)
I find that the -and in find commands are almost always overkill. Example.
find . -type f ! -type d
Same as
find . -type f -and ! -type d
Also the -f flag is an option to add to the tracks to move. I don't believe this is an expression. Please "search" for clarification.
a source to share
I-image in man
Operator - and is a logical AND operator. Since it is implied, matching two expressions does not have to be specified. The expression evaluates to true if both expressions are true. The second expression is not evaluated if the first expression is false.
This part of the guide is rather cryptic to me. However, analyze it.
1st sentence: like AND operator in Math. Two two only
2nd sentente: This says you don't need to use the command as you can see in Dave's answer. Large! - - It seems juxpose is the first expression with -AND and one without -AND. Please clarify this Greek for me.
Third sentence: repetition: he says the same thing in the first sentence with the word "logical".
4th clause: repeat: it says 01 implies false
The same in English:
Let p and q be two expressions with the following truth values
p q pANDq
1 1 1
1 0 0
0 1 0
0 0 0
where 1 means true and 0 means false.
Please note that manuals are often redundant and sometimes erroneous.
a source to share