0

I am trying to ignore the order of the words and searching for the line in one file which has below pattern for example : My Name is ABC.

Now I want to change the sequence of words in the same sentence as below : ABC is my name.

Can someone please help me on how should I find this line in linux, if the order/sequence of the words keeps changing ?

Thanks in advance.

  • 1
    Do you want to extract the name? or just print the whole like if it matches either of the patterns? – cas Jun 14 '21 at 05:56
  • 1
    You want to find all lines which include all four words in any order? A trivial attempt for this would be to pipe through several greps like this: grep -i ABC infile | grep -i my | grep -i is | grep -i name (The option -i to ignore a change in case when words are at the beginning of the sentence). – Philippos Jun 14 '21 at 06:04
  • @Philippos you probably ought to include -w on those so that words containing these as substrings aren't matched, such as sister – Chris Davies Jun 14 '21 at 06:54

0 Answers0