Is there a way to get grep to match the exact string and not parse it as a regular expression? Or is there any tool for the right line for grep?
$ version=10.4 $ echo "10.4" | grep $version 10.4 $ echo "1034" | grep $version # shouldn't match 1034
Use grep -F or fgrep.
$ echo "1034" | grep -F $version # shouldn't match $ echo "10.4" | grep -F $version 10.4
See the man page:
-F, --fixed-strings Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched.
I searched for the term "literal match" or "fixed string".
(See also Using grep with a complex string and How can grep literally interpret a string containing an asterisk and feed it into grep through a variable? )
This should work ... this works for me:
echo "1034" | grep "10\.4"
Source: https://habr.com/ru/post/892298/More articles:Excel: Break on Error not working in custom function - debuggingRetrieving master data objects but not sub-objects - cocoahttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/892295/facebook-like-button-flips-backs-to-unliked-state-after-clicking&usg=ALkJrhjf4yY-QqqnRiy63tbBZH9EiggJfgSurfaceView blank when playing a media player - androidSliding panel returns to home when clicked - jqueryHow to handle ConcurrentModificationException in Android - javaUsing grep with a complex string - bashHow can grep interpret literally a string containing an asterisk and is passed to grep through a variable? - bashJUnit Launcher test ... getActivity not returning - androidDo I need to assign a default value to the option returned by the Delphi function? - functionAll Articles