I have a log file with a list of many entries. With grep regex I want to match the first word and another word which can be anywhere in the string.
For example, if I specified "user1" the search would search:
grep -E '^(IP_CONNECT|IP_DISCONNECT) user1' file.txt
However this won't match unless user1 is at the beginning of the string whereas I want to match it if it appears anywhere in the string. How is this done?
^(IP_CONNECT|IP_DISCONNECT) user1
means "start of line followed by IP_CONNECT or IP_DISCONNECT, then a single space, then user1". Is this really what you want to match on?