How to search for an exact word with the grep command

2

Well, whenever I use the grep command it looks for a word that contains the desired word + anything, how can I make it understand that I just want that word and nothing else? ex:

ps aux|grep bc

Instead of looking for it

...... bcache
...... bclink
...... bc
......
......

Look for only the word bc

......bc
    
asked by anonymous 15.07.2018 / 00:04

1 answer

8

Use the option --word-regexp or simply -w , for example:

ps aux | grep -w bc

The above parameter will return only the line containing the entered word (not just a part of it) preceded by non-constituent characters (letters, numbers, and underscores).

    
15.07.2018 / 00:11