From 7cdb5fd5e253a1aa8d8219feff6a0dafe96307ff Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Mon, 13 Jan 2025 02:19:01 +0100 Subject: [PATCH] https://github.com/koalaman/shellcheck/issues/3113 --- SC2013.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SC2013.md b/SC2013.md index c405c49..948005c 100644 --- a/SC2013.md +++ b/SC2013.md @@ -12,7 +12,7 @@ done ### Correct code: ```sh -grep -v '^ *#' < file | while IFS= read -r line +grep -v '^ *#' file | while IFS= read -r line do echo "Line: $line" done @@ -24,14 +24,14 @@ or without a subshell (bash, zsh, ksh): while IFS= read -r line do echo "Line: $line" -done < <(grep -v '^ *#' < file) +done < <(grep -v '^ *#' file) ``` or without a subshell, with a pipe (more portable, but write a file on the filesystem): ```sh mkfifo mypipe -grep -v '^ *#' < file > mypipe & +grep -v '^ *#' file > mypipe & while IFS= read -r line do echo "Line: $line"