Patterns can be specified as regular expressions:
/regular expression/ {action}
For example:
echo "[email protected]
not an email" | awk '/[^@]+@.+/ {print}'
Produces:
[email protected]
Note that an action consisting only of the print
statement can be omitted entirely. The above example is equivalent to:
echo "[email protected]
not an email" | awk '/[^@]+@.+/'