Where to start First steps track · 15 stages
Linux Labs

Regular expressions — patterns for grep, sed and awk

cheat sheet · Ubuntu 24.04 · GNU grep 3.11 · GNU sed 4.9 https://lab.dimsanych.ru/en/wiki/regex/

Cheat sheet

  • grep -i 'error' app.log ignore case
  • grep -E 'error|fail' app.log either word
  • grep 'error\|fail' app.log the same in GNU basic syntax
  • grep -w 'err' app.log a whole word: not terror
  • grep -oE '\berr\b' app.log the same with word boundaries
  • grep -E '^[0-9]+$' file a line of digits only
  • grep -F '10.20.0.15' file literally, no special characters
  • sed -E 's/^(\w+) *= */\1=/' app.ini group \1 in a replacement
Loading…