Bash Return Only First Line That Contains Match For Each

[Solved] Bash Return Only First Line That Contains Match For Each | Perl - Code Explorer | yomemimo.com
Question : bash return only first line that contains match

Answered by : charlesalexandre-roy

# 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 : https://stackoverflow.com/questions/50263627/how-to-extract-only-first-line-that-matches-each-pattern-from-a-file | Last Update : Mon, 03 May 21

Answers related to bash return only first line that contains match for each line in a file

Code Explorer Popular Question For Perl