Artificial intelligent assistant

just grep multiple pattern on different row I have file.txt A2 RP FAULT A2 RP FAULT A2 CELL A2 CELL how I can just grep 2 words: `A2 & RP FAULT`, The result should be : A2 RP FAULT A2 RP FAULT what I try : cat file.txt | grep -E "A2|RP FAULT" but the result like this A2 RP FAULT A2 RP FAULT A2 A2

Your `grep -E` command does what you wrote in the subject, but I guess what you really want is to show the `A2` lines with the "status" if the following line is `RP FAULT`. Right?


cat file.txt | grep -A 1 "A2" | grep -B 1 'RP FAULT'


The `-A n` shows `n` lines after the match, the `-B n` shows lines before.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy d35d28c0cdde2a31970a093a0b06c7c3