From c5a6d87c5e791d8eeb9554f00f2ebc8e771b8079 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sat, 7 Jan 2017 14:31:05 +0100 Subject: [PATCH] Add while-read example to read docs --- doc_src/read.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc_src/read.txt b/doc_src/read.txt index 3f41a871b..5514bc848 100644 --- a/doc_src/read.txt +++ b/doc_src/read.txt @@ -51,4 +51,9 @@ The following code stores the value 'hello' in the shell variable `$foo`. \fish echo hello|read foo + +# This is a neat way to handle command output by-line: +printf '%s\n' line1 line2 line3 line4 | while read -l foo + echo "This is another line: $foo" + end \endfish