From 47218d271f20b39610d5f63b3bc7dfc86642bdba Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Fri, 23 Sep 2022 20:47:12 +0200 Subject: awk: add example with negative pattern --- src/tools/awk.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/tools') diff --git a/src/tools/awk.md b/src/tools/awk.md index 7ffe9a8..5fc3184 100644 --- a/src/tools/awk.md +++ b/src/tools/awk.md @@ -102,6 +102,12 @@ awk 'NR%2 == 0 { print $0 }' The pattern `NR%2 == 0` matches every second record and the action `{ print $0 }` prints the whole record. +### Negative patterns +```bash +awk '!/^#/ { print $1 }' +``` +Matches records not starting with `#`. + ### Access last fields in records ```bash echo 'a b c d e f' | awk '{ print $NF $(NF-1) }' -- cgit v1.2.3