This is a really stupid question but I can't find an answer anywhere. So I have a command that prints out lines of text like this:


And I need to check for a line, not a substring

2 Answers 2


Use anchors... for example:

grep '^kvantum$' ...
  • 1
    With GNU grep, there's also the -x / --line-regexp option which is "like parenthesizing the pattern and then surrounding it with ^ and $" Jul 13, 2021 at 23:53

Bot sed and grep utilize regular expressions. If you want to match a plain text string awk can be a good alternative.

$0 in awk is entire line - or more precise record separated by RS which defaults to newline.

awk '$0 == "some line with $ and * and ..."' file

Or by variable:

awk -v find='some line with $ and * and ...' '$0 == find' file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.