commit: ed4fcf21d6d0fea974ad714ce4caa688652dddc2
parent d787122f672d9ccd53c36ffa9f8a2a941903dda9
Author: Drew DeVault <sir@cmpwn.com>
Date: Tue, 4 May 2021 13:44:40 -0400
Improve awk snippet
Thanks to Matthieu Rakotojaona for the suggestion!
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/content/blog/awk-is-the-coolest-tool-you-dont-know.gmi b/content/blog/awk-is-the-coolest-tool-you-dont-know.gmi
@@ -149,7 +149,7 @@ Sometimes I have a file and I want it to have line numbers. So, I wrote a little
```
$ cat ~/bin/lineno
-exec awk 'BEGIN { n = 1; } { print n "\t" $0; n = n + 1 }'
+exec awk '{ print NR "\t" $0 }'
$ lineno < /etc/os-release
1 NAME="Alpine Linux"
2 ID=alpine