De Morgan Law Let learning Liunx's small partners around the headache, now I use the force of the primitive to straighten out this law for everyone.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/85/E7/wKiom1etwHLSIrxXAAAskZ0cql4503.jpg "title=" de Morgan's law. jpg "alt=" wkiom1etwhlsirxxaaaskz0cql4503.jpg "/>
As can be seen from the picture,
A=4+3
B=3+2
Non-a=2+1
Non-b=4+1
A and b means that both A and B are in place, A and b are colored block 3, so the color block 3 represents a and B
At the same time, we look at A=4+3, b=3+2, and we can infer that The result of the operation is the number of repetitions in the two arithmetic formula.
A and b=3
A or B is either a part of a or a part of B, so the color block 2,3,4 and represents the range of a or B. Looking at a=4+3,b=3+2, we can infer that the result of the operation is that all the numbers in the two arithmetic are added, and the repeated numbers are added only once.
A or b=2+3+4
A non-color block is the sum of all the other color blocks in addition to this color block. A non-n color block is the sum of other color blocks except for the n-color blocks.
Cases:
Non-3=1+2+4
As a result, we can perform the following operations
(not a) or (not b) = (2+1) or (4+1) =1+2+4
Non (A and B) = Non (4+3 and 3+2) = Non (3) =1+2+4
(Not a) and (not B) = (2+1) and (4+1) =1
Non (A or B) = Non (4+3 or 3+2) = Non (4+3+2) =1
We can draw the following conclusions:
(not a) or (not B) = Non (A and B)
(Non-a) and (not B) = Non (A or B)
Let's do the following exercises:
Chmod-rw/tmp/file1, write the script/root/bin/per.sh to determine if the current user is unreadable to the/tmp/fiile1 file and is not writable
Method One:
[email protected] bin]# cat per.sh
#!/bin/bash
[!-r/tmp/file1-a!-w/tmp/file1] && echo "You can ' t read and write/tmp/file1" | | echo "You can read or write/tmp/file1"
Method Two:
[email protected] bin]# cat per2.sh
#!/bin/bash
! [-r/tmp/file1-o-w/tmp/file1] && echo "You can ' t read and write/tmp/file1" | | echo "You can read or write/tmp/file1"
The red mark is a different place in two statements, but the function is the same.
This article is from the "zebra930" blog, make sure to keep this source http://zebra930.blog.51cto.com/11736340/1837433
Open Linux De Morgan Law with primitive force