From 4cf96f0f7df3e87b65e7d10f3fc882b4feddcc62 Mon Sep 17 00:00:00 2001 From: Tran Dinh Dong <76928878+vanvuvuong@users.noreply.github.com> Date: Sun, 25 Aug 2024 21:17:39 +0700 Subject: [PATCH] awk: update page (#13446) --- pages/common/awk.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/common/awk.md b/pages/common/awk.md index f8bf29b0c2..fc1346bd2d 100644 --- a/pages/common/awk.md +++ b/pages/common/awk.md @@ -27,10 +27,10 @@ `awk '{if ($1 == "foo") print "Exact match foo"; else if ($1 ~ "bar") print "Partial match bar"; else print "Baz"}' {{path/to/file}}` -- Print all lines where the 10th column value equals the specified value: - -`awk '($10 == {{value}})'` - - Print all the lines which the 10th column value is between a min and a max: `awk '($10 >= {{min_value}} && $10 <= {{max_value}})'` + +- Print table of users with UID >=1000 with header and formatted output, using colon as separator (`%-20s` mean: 20 left-align string characters, `%6s` means: 6 right-align string characters): + +`awk 'BEGIN {FS=":";printf "%-20s %6s %25s\n", "Name", "UID", "Shell"} $4 >= 1000 {printf "%-20s %6d %25s\n", $1, $4, $7}' /etc/passwd`