1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-03-28 21:16:20 +01:00

awk: update page (#13446)

This commit is contained in:
Tran Dinh Dong 2024-08-25 21:17:39 +07:00 committed by GitHub
parent 5b1da1d5ae
commit 4cf96f0f7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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`