match exact grep
echo olavo|grep -E "^olavo$" # returns olavo
echo olavo|grep -E "ola$" # returns none
Tiago F2
echo olavo|grep -E "^olavo$" # returns olavo
echo olavo|grep -E "ola$" # returns none
grep -rn regex_search folder_where_to_search
#Ex: search pattern in "." current folder (r) recursively
grep -rn pattern .
Just combine grep with head command for filtering only the first match as:
grep "match" | head -n 1 #Change 1 to not only match first but further matches
$ grep "PATTERN1\|PATTERN2" FILE
$ grep -E "PATTERN1|PATTERN2" FILE
$ grep -e PATTERN1 -e PATTERN2 FILE
$ egrep "PATTERN1|PATTERN2" FILE