intersection of shell programming, union, complement

1. A method grep -f (the intersection of two files, not effective)

File a

cat a
12
34
13
25

File b

cat b
13
35
78
14

(1). Intersection

grep -f a b
13

(2) complement

a-b

grep -v -f b a

12
34
25

b-a

grep -v -f b a

(3). Union

 

2. Method Two sort

(1). Intersection

sort a b|uniq -d

Union

sort a b|uniq 

Complement

a-b

sort a b b|uniq -u

Guess you like

Origin www.cnblogs.com/sun5/p/11917371.html