diff --git a/SC2013.md b/SC2013.md index f5b5c88..74c2818 100644 --- a/SC2013.md +++ b/SC2013.md @@ -27,6 +27,17 @@ do done < <(grep -v '^ *#' < file) ``` +or without a subshell, with a pipe (more portable, but write a file on the filesystem): + +```sh +mkfifo mypipe +while IFS= read -r line +do + echo "Line: $line" +done < mypipe +rm mypipe +``` + ### Rationale: For loops by default (subject to `$IFS`) read word by word. Additionally, glob expansion will occur.