Unix/Linux

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Grabing input from a keyboard while reading from a file

    1 answers - 481 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi everybody,
    Sample file:
    1
    2
    3
    4
    My script:
    cat file |
    while read abc
    do
    echo "Do you want to continue with $abc"
    read answer
    done
    The problem is "while read abc" will get 1, "read answer" will get 2
    instead of waiting for user input from a keyboard. Is there a way to
    tell read or any other command to wait for user input instead of
    reading the next value from a file?
    Thanks,
    Greg
  • No.1 | | 517 bytes | |

    2006-03-10, gregruzis@gmail.com wrote:
    Hi everybody,

    Sample file:
    1
    2
    3
    4
    --
    My script:

    cat file |
    while read abc
    do
    echo "Do you want to continue with $abc"
    read answer

    done

    The problem is "while read abc" will get 1, "read answer" will get 2
    instead of waiting for user input from a keyboard. Is there a way to
    tell read or any other command to wait for user input instead of
    reading the next value from a file?

    read answer < /dev/tty

Re: Grabing input from a keyboard while reading from a file


max 4000 letters.
Your nickname that display:
In order to stop the spam: 0 + 9 =
QUESTION ON "Unix/Linux"

EMSDN.COM