Bash fucntion read from standard input

I what do pipe the standard input of sort or grep to a function and then have operations performs on each line.

function speak {
echo the standard input
}

grep test text.txt | speak

Thanks for any help
LVL 2
jculkincysAsked:
Who is Participating?
 
ravenplConnect With a Mentor Commented:
#rather:
function speak {
 while read -s INPUT; do echo $INPUT; done
}
#right?
0
 
m1tk4Connect With a Mentor Commented:

function speak {
   read -s INPUT
   echo $INPUT
}
grep test text.txt | speak

http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_08_02.html for more details
0
 
jculkincysAuthor Commented:
There would be multiple outline outputted from grep so it seems I would need WHILE

Is this correct?
I will try to test and get back
0
All Courses

From novice to tech pro — start learning today.