From 8babd914417432879f0f88e12e3270b442bf7544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?imme=C3=ABmosol?= Date: Sat, 13 Jan 2024 20:26:49 +0100 Subject: [PATCH] Saw the previous revision :/ Made the sh-example even simpler --- SC2031.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/SC2031.md b/SC2031.md index 9468d8a..b875176 100644 --- a/SC2031.md +++ b/SC2031.md @@ -18,13 +18,23 @@ n=0 while read i; do (( n+=i )); done < <(printf "%s\n" {1..10}) echo $n ``` -In `sh`, temporary files, FIFOs or file descriptors can be used instead. When the output of the command can be stored to a variable before entering the loop, here documents are a preferable alternative: +In `sh`, temporary files, FIFOs or file descriptors can be used instead. When the output of the command can be stored to a variable before entering the loop, here documents are a preferable alternative. ```sh n=0 -SUMMANDS="$(printf '%s\n' 1 2 3 4 5 6 7 8 9 10)" -while read i; do n=$(( n + i )); done <