Answers for "grep check line exists in file"

0

grep check line exists in file

grep -F -q -e 'search string' textfile.txt || echo 'Not found'
Note:

-F prevents the interpretation of the search string as a regular expression.
-q suppresses all output and returns immediately after the first instance was found, making the search much faster if the string occurs at the beginning of a large file.
-e specifies the pattern explicitly, allowing patterns that start with a dash.
Use single quotes unless you want variable substitutions.
Posted by: Guest on March-21-2022

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language