Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

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.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #grep #check #line #exists #file
ADD COMMENT
Topic
Name
3+6 =