0

File 1

 rta a xxx
 qqq b qqq
 rta c xxx
 qqq d qqq

File 2

qwe d vzc
wex c xcz
vfx b cvz
vcv a asd

The output I want in File 2

 qqq d qqq
 rta c xxx
 qqq b qqq
 rta a xxx

i need to try the match a certain word like column two and replace the words in column one and column two based on the words search .

3
  • What you had tried so far ?
    – SHW
    Sep 22, 2016 at 7:40
  • i try use the grep grep ‘a' File2 | sed 's/vcv/qqq/'
    – heng960407
    Sep 22, 2016 at 7:42
  • but this command take a lot of time if i want to compare many characters to replace,any faster ways to just auto search and replace the words
    – heng960407
    Sep 22, 2016 at 7:43

1 Answer 1

0

If order in result is no matter:

grep -Fwf <(tr -s ' ' '\t' <file2|cut -f2) file1
1
  • thank you ,i use grep aslo but different command from u
    – heng960407
    Sep 22, 2016 at 9:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .