Patterns

Other topics

Regexp Patterns

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 '/[^@]+@.+/'

Contributors

Topic Id: 3475

Example Ids: 12007

This site is not affiliated with any of the contributors.