while read var; do
echo "Var=$var"
done
Main Topics
Browse All Topicsi am new to shell programming.
the situation is like this...
i read a command from the console,and store it in a variable.
i did it using "read var".
now the problem is...
how can i detect if it is EOF.
this is necessary because, some file may be redirected to my program.
i tried with some thing like...
if ($var = EOF)
etc. but no use.
please help me.
thanks in advance.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
What ahoffman means is that when an end-of-file (EOF) is reached (or control-d pressed to generate an EOF), the statements inside the while loop are no longer executed. therefore you cannot test for EOF inside the while loop.
His short solution is the correct one, mine was only an example of how to break the loop when a null (CR) is read.
Business Accounts
Answer for Membership
by: sunilvirusPosted on 2002-08-05 at 00:14:15ID: 7200280
i also tried using...
if ( $var )
but not working