From 4823b8018688092416b3cd4ba9f4f7f86789eedd Mon Sep 17 00:00:00 2001
From: johannst Any valid awk An example is the regex pattern awk provides two special patterns, expr
can be a 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
BEGIN
and END
, which can be used
multiple times. Actions with those patterns are executed exactly once.
%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.
awk '!/^#/ { print $1 }' <file>
Matches records not starting with #
.
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 } }'
+
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