#!/bin/bash # echo -e "hello\nworld" | ./show-pipe #first reply: hello #second reply: world # echo "hello world" | ./show-pipe #first reply: hello world #second reply: function example1 () { read VAR=$REPLY echo "first reply: "$REPLY"" #VAR=$REPLY #echo $VAR echo "Number of ARGS: $#" OTHER=$1 echo $OTHER read echo "second reply: "$REPLY"" exit 0 } # Another example LINE_COUNT=0 while read LINE ; do (( LINE_COUNT++ )) echo LINE:$LINE_COUNT:$LINE done #exit # # example of using read with catted input LINE_COUNT=0 cat ./sq.txt | while read LINE ; do (( LINE_COUNT++ )) echo LINE:$LINE_COUNT:$LINE done exit #