Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
commands:builtin:read [2013/04/14 12:31]
thebonsai Don't tread version 4 special - it has been around for a long time now
commands:builtin:read [2018/07/17 08:42] (current)
thebonsai [Synopsis]
Line 4: Line 4:
 ===== Synopsis ===== ===== Synopsis =====
 <​code>​ <​code>​
-read [-ers] [-u <FD>] [-t <​TIMEOUT>​] [-p <​PROMPT>​] [-a <​ARRAY>​] [-n <​NCHARS>​] [-d <​DELIM>​] [-i <​TEXT>​] [<​NAME...>​]+read [-ers] [-u <FD>] [-t <​TIMEOUT>​] [-p <​PROMPT>​] [-a <​ARRAY>​] [-n <​NCHARS>​] [-N <​NCHARS>​] [-d <​DELIM>​] [-i <​TEXT>​] [<​NAME...>​]
 </​code>​ </​code>​
  
Line 29: Line 29:
 while IFS= read -r; do while IFS= read -r; do
   line=$REPLY   line=$REPLY
 +  ...
 +done < text.txt
 +</​code>​
 +
 +Alternately,​ you can enclose $REPLY in double quotes and avoid fiddling with IFS altogether:
 +
 +<​code>​
 +while read -r; do
 +  line="​$REPLY"​
   ...   ...
 done < text.txt done < text.txt
  • commands/builtin/read.1365942699.txt
  • Last modified: 2013/04/14 12:31
  • by thebonsai