user3815726 user3815726 - 5 months ago 16
Linux Question

Linux - grep to exclude all words in front searched pattern

For example, whey I type:

grep Eth test.sh


I will get

Summary: Ethernet settings tool for PCI ethernet cards


Say if I only need my searched pattern and exlucde all words ahead

Ethernet settings tool for PCI ethernet cards


How can I do this in grep?

Answer

With GNU grep:

grep -Po '\KEth.*' test.sh

Output:

Ethernet settings tool for PCI ethernet cards
Comments