Bash fucntion read from standard input

Posted on 2006-04-24
Last Modified: 2010-04-20
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
Question by:jculkincys
    LVL 15

    Assisted Solution


    function speak {
       read -s INPUT
       echo $INPUT
    grep test text.txt | speak for more details
    LVL 43

    Accepted Solution

    function speak {
     while read -s INPUT; do echo $INPUT; done
    LVL 2

    Author Comment

    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

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now