Here is the list.txt file:
001 Linux000
002 Linux001
003 Linux002
cat list.txt | grep 002
returns:
002 Linux001
003 Linux002
But I need to get only lines where is 002, not Linux002.
002 Linux001
CodePudding user response:
Taking word boundaries (\b
) into account with GNU grep:
grep '\b002\b' list.txt
CodePudding user response:
Does this grep
work?
$ grep '\<002\>' input_file
002 Linux001