Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash grep only return first match

# Basic syntax:
grep -m 1 "pattern" input_file.txt
# Where -m is the maximum number of matching lines to return, i.e. stop
#	reading the file after m matches
# Note, this is more efficient than piping to head because there you
#	always read the whole file even if you're only looking for m matches
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bash #grep #return #match
ADD COMMENT
Topic
Name
3+4 =