From 358833ec9c9c230c631d9bd5f29cb27d1cb273d1 Mon Sep 17 00:00:00 2001 From: johannst Date: Wed, 28 Jul 2021 23:48:28 +0200 Subject: awk: fix type and add sprintf --- src/tools/awk.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/tools') diff --git a/src/tools/awk.md b/src/tools/awk.md index f8aa0a8..9ea4fc5 100644 --- a/src/tools/awk.md +++ b/src/tools/awk.md @@ -75,6 +75,11 @@ multiple times. Actions with those patterns are **executed exactly once**. For floats one can use `%N.Mf`, `N` is the total number including `.` and `M`. +- `sprintf("fmt", expr, ...)` + + Format the expressions according to the format string. Similar as `printf`, + but this is a function and return value can be assigned to a variable. + - `strftime("fmt")` Print time stamp formatted by `fmt`. @@ -101,7 +106,7 @@ prints the whole record. ```bash echo 'a b c d e f' | awk '{ print $NF $(NF-1) }' ``` -Access last fields with arithmetic on the `NR` number of fields variable. +Access last fields with arithmetic on the `NF` number of fields variable. ### Capture in variables ```bash -- cgit v1.2.3