From 4823b8018688092416b3cd4ba9f4f7f86789eedd Mon Sep 17 00:00:00 2001 From: johannst Date: Tue, 12 Dec 2023 23:48:13 +0000 Subject: deploy: 4ed29d46d45a751071d89be37c87de71204efda4 --- tools/awk.html | 29 ++++++++++++++++++++++++++++- tools/bash.html | 4 +++- tools/dot.html | 4 +++- tools/emacs.html | 4 +++- tools/fish.html | 4 +++- tools/gdb.html | 4 +++- tools/gdbserver.html | 4 +++- tools/git.html | 4 +++- tools/gpg.html | 4 +++- tools/index.html | 4 +++- tools/pacman.html | 4 +++- tools/qemu.html | 4 +++- tools/radare2.html | 4 +++- tools/tmux.html | 4 +++- tools/zsh.html | 4 +++- 15 files changed, 70 insertions(+), 15 deletions(-) (limited to 'tools') diff --git a/tools/awk.html b/tools/awk.html index efd30b7..3da3746 100644 --- a/tools/awk.html +++ b/tools/awk.html @@ -90,7 +90,9 @@ - + @@ -213,6 +215,10 @@ record ----> ∀ pattern matched fields ----> run associated action

Any valid awk expr can be a pattern.

+

An example is the regex pattern /abc/ { print $1 } which prints the first +field if the record matches the regex /abc/. This form is actually a short +version for $0 ~ /abc/ { print $1 }, see the regex comparison operator +below.

Special pattern

awk provides two special patterns, BEGIN and END, which can be used multiple times. Actions with those patterns are executed exactly once.

@@ -263,6 +269,15 @@ but this is a function and return value can be assigned to a variable.

  • %T alias for %H:%M:%S
  • +
  • +

    S ~ R, S !~ R

    +

    The regex comparison operator, where the former returns true if the string +S matches the regex R, and the latter is the negated form. +The regex can be either a +constant +or dynamic +regex.

    +
  • Examples

    Filter records

    @@ -274,6 +289,18 @@ prints the whole record.

    awk '!/^#/ { print $1 }' <file>
     

    Matches records not starting with #.

    +

    Range patterns

    +
    echo -e "a\nFOO\nb\nc\nBAR\nd" | \
    +    awk '/FOO/,/BAR/ { print }'
    +
    +

    /FOO/,/BAR/ define a range pattern of begin_pattern, end_pattern. When +begin_pattern is matched the range is turned on and when the +end_pattern is matched the range is turned off. This matches every record +in the range inclusive.

    +

    An exclusive range must be handled explicitly, for example as follows.

    +
    echo -e "a\nFOO\nb\nc\nBAR\nd" | \
    +    awk '/FOO/,/BAR/ { if (!($1 ~ "FOO") && !($1 ~ "BAR")) { print } }'
    +

    Access last fields in records

    echo 'a b c d e f' | awk '{ print $NF $(NF-1) }'
     
    diff --git a/tools/bash.html b/tools/bash.html index 2418872..13551e7 100644 --- a/tools/bash.html +++ b/tools/bash.html @@ -90,7 +90,9 @@ - + diff --git a/tools/dot.html b/tools/dot.html index 9b5d5be..6271fd3 100644 --- a/tools/dot.html +++ b/tools/dot.html @@ -90,7 +90,9 @@ - + diff --git a/tools/emacs.html b/tools/emacs.html index 388937e..d9e280c 100644 --- a/tools/emacs.html +++ b/tools/emacs.html @@ -90,7 +90,9 @@ - + diff --git a/tools/fish.html b/tools/fish.html index 9f1a556..0eba250 100644 --- a/tools/fish.html +++ b/tools/fish.html @@ -90,7 +90,9 @@ - + diff --git a/tools/gdb.html b/tools/gdb.html index b0e26cd..d618890 100644 --- a/tools/gdb.html +++ b/tools/gdb.html @@ -90,7 +90,9 @@ - + diff --git a/tools/gdbserver.html b/tools/gdbserver.html index 7821377..8935f53 100644 --- a/tools/gdbserver.html +++ b/tools/gdbserver.html @@ -90,7 +90,9 @@ - + diff --git a/tools/git.html b/tools/git.html index e3c1f93..b09128f 100644 --- a/tools/git.html +++ b/tools/git.html @@ -90,7 +90,9 @@ - + diff --git a/tools/gpg.html b/tools/gpg.html index b03234f..82c8088 100644 --- a/tools/gpg.html +++ b/tools/gpg.html @@ -90,7 +90,9 @@ - + diff --git a/tools/index.html b/tools/index.html index 4139c7d..88f0809 100644 --- a/tools/index.html +++ b/tools/index.html @@ -90,7 +90,9 @@ - + diff --git a/tools/pacman.html b/tools/pacman.html index 5a0fc53..c1bcd48 100644 --- a/tools/pacman.html +++ b/tools/pacman.html @@ -90,7 +90,9 @@ - + diff --git a/tools/qemu.html b/tools/qemu.html index 265c7bc..6bdeda2 100644 --- a/tools/qemu.html +++ b/tools/qemu.html @@ -90,7 +90,9 @@ - + diff --git a/tools/radare2.html b/tools/radare2.html index 7e2ff73..e3732c6 100644 --- a/tools/radare2.html +++ b/tools/radare2.html @@ -90,7 +90,9 @@ - + diff --git a/tools/tmux.html b/tools/tmux.html index d9ae07c..d1de9cb 100644 --- a/tools/tmux.html +++ b/tools/tmux.html @@ -90,7 +90,9 @@ - + diff --git a/tools/zsh.html b/tools/zsh.html index a588517..0fdd85e 100644 --- a/tools/zsh.html +++ b/tools/zsh.html @@ -90,7 +90,9 @@ - + -- cgit v1.2.3