Home > OS >  Equipped with two files the same keyword
Equipped with two files the same keyword

Time:11-18

Consult
Equipped with the following two files the same keyword lines
Sample] [root @ 10-9-135-73 # cat aaa
1 the FSF Chen tao yi tea
1 Chen Daoyi tea
1 f Chen tea
2 f leaf Chen
3 f to Chen leaves I
4 the fs Chen apart
1 f decomposition machine Chen yi tea
2 Chen fs
Chen fs parity bit 0
2 the play tease
Two Russian hmhio tease
2 MKLGRT
2 the HKGW
2 the gkore
Two Russian koi009 tease
Two Russian kt309u0 tease
Two Russian gkoi03 tease
Two Russian it90 tease
1 finkel v easy
Fk1 - fk 0 Canaan
1 MFJ far
Paulo: here's airliner Buddha I 1 fk1 - FK fai I
1 FKKLS
the more month0 DFL xian bin is
1 DVGW doug
Line 1 ff on tea
1 e modest to illegal
1 dfef independently
0 if efewew
1 stereotypes Chen Xinghong
1 word jade
Fitow 1
1 li FDS
1 e handsome Chen Yiming
More than 1 e since Chen
1 e Chen Shengqiang
1 - felkfo
1 the dk ear
Sample] [root @ 10-9-135-73 # cat BBB
Chen * * * * * * * * road, leaf
The * * * * to make
Mr * * * * away
F * * * * south
M * * * *
F * * * * I
F * * * *
D * * * * his
D * * * * bean
F * * * * line
Method of e * * * *
D * * * *,
If w * * * *
Red word * * * *
Jade say * * * *
Fe * * * *,
Li * * * * s
* * * * e inscription
* * * * e much
* * * * e strong
- * * * * o
D * * * * east
Sample] [root @ 10-9-135-73 #

CodePudding user response:

This can solve the two files the same string
Sample] [root @ 10-9-135-73 # grep - wf BBB aaa
1 word jade
1 fitow

CodePudding user response:

How to solve the two files in the
As long as there are two key words can match a triple rows in the output file

CodePudding user response:

Can remove the - w, - w options mean accurate search, is completely in accordance with the BBB in matching search, if it is grep -f BBB aaa should be the results you want

CodePudding user response:

But
Grep -f BBB aaa find out
4 the fs Chen apart
2 Chen fs
Chen fs parity bit 0
Not in the BBB
Sample] [root @ 10-9-135-73 # cat BBB | grep ^ Chen. * [a] $
Sample] [root @ 10-9-135-73 # cat BBB | grep ^ Chen. * [and] $
Sample] [root @ 10-9-135-73 # cat BBB | grep ^ Chen. * [a] $

CodePudding user response:

Whether can use the
Sample] [root @ 10-9-135-73 # cat BBB | awk - F * * * * "" '{print $1}' do grep ^ (start)
And
Sample] [root @ 10-9-135-73 # cat BBB | awk - F * * * * "" '{print $NF}' do grep $(end)
?

CodePudding user response:

Aaa file can be in the second column to the appearance of BBB
Sample] [root @ 10-9-135-73 # cat aaa | head - 5
1 the FSF Chen tao yi tea
1 Chen Daoyi tea
1 f Chen tea
2 f leaf Chen
3 f to Chen leaves I
Sample] [root @ 10-9-135-73 # cat BBB | head - 5
Chen * * * * * * * * road, leaf
The * * * * to make
Mr * * * * away
F * * * * south
M * * * *
Sample] [root @ 10-9-135-73 # grep - Ff BBB CCC
Chen * * * * leaves 1
Chen * * * * leaves 1
Chen * * * * leaves 1
Chen * * * * leaves 2
Chen * * * * futaba 3
The * * * * to make 2
This
Grep - Ff and grep - the difference between wf
Sample] [root @ 10-9-135-73 # grep - wf BBB CCC
Chen * * * * leaf> 1
Chen * * * * leaf> 1
Chen * * * * leaf> 1
Chen * * * * leaf> 2
Chen * * * * leaf> 3
The * * * * with
The * * * * with
The * * * * w 2
If * * * * w
It matches only the last red, such as the above
The * * * * w 2
If * * * * w
BBB file not
The w * * * *
Want to match it also match up the
Sample] [root @ 10-9-135-73 # grep - Ff BBB CCC
* * * * leaf Chen 1
* * * * leaf Chen 1
* * * * leaf Chen 1
* * * * leaf Chen 2
* * * * leaf Chen 3
* * * * to make Russia 2
* * * * to make Russia 2
* * * * to make Russia 2
This will come out to match all the red font,
  • Related