diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2022-09-23 20:47:12 +0200 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2022-09-23 20:47:12 +0200 |
commit | 47218d271f20b39610d5f63b3bc7dfc86642bdba (patch) | |
tree | 968816a7e6b4cb366c9f098bff22635390134f1c /src | |
parent | 29c1b6a06f8d5c546fbd5514731c4ac4c504f6c3 (diff) | |
download | notes-47218d271f20b39610d5f63b3bc7dfc86642bdba.tar.gz notes-47218d271f20b39610d5f63b3bc7dfc86642bdba.zip |
awk: add example with negative pattern
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/awk.md | 6 |
1 files changed, 6 insertions, 0 deletions
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 }' <file> The pattern `NR%2 == 0` matches every second record and the action `{ print $0 }` prints the whole record. +### Negative patterns +```bash +awk '!/^#/ { print $1 }' <file> +``` +Matches records not starting with `#`. + ### Access last fields in records ```bash echo 'a b c d e f' | awk '{ print $NF $(NF-1) }' |