I need some help with some bash. I've only learnt like grep, awk, find, sed etc.
Say I have a file named people.txt
with different names on a line on multiple lines but a name appears in every line. For example:
Ln1 - chris butcher, sam witwickie, joseph stalin, king kunta
Ln2 - Thor, ironman, mariah carey, chris butcher
Ln3 - jen love, chris butcher, jeep lake
How would I print chris butcher's name on each line? Note that chris butcher's name appear on different parts of the line
The expected result I would like is:
Ln1 - chris butcher
Ln2 - chris butcher
Ln3 - chris butcher
I know that grep -i "chris butcher" would highlight the names in each line but I need it to print just 'chris butcher' in each line as the result.
Thanks in advanced!
grep
, you are presumably aware of its-o
or--only-matching
option? – steeldriver Dec 15 '22 at 02:03