Print lines matching a regex in awk.
Section: grep, egrep, and ripgrep
awk regex condition
bash
bash
awk '/^[0-9]{4}-[0-9]{2}-[0-9]{2}/ { print }' file.txtExplanation
awk uses regex in pattern positions for line filtering.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing grep, egrep, and ripgrep
ripgrep with PCRE2
Use lookbehind or advanced features through PCRE2 mode.
sed regex replacement
Replace all runs of whitespace with a single space.