Re: while loop
- From: Ed Morton <morton@xxxxxxxxxxxxxx>
- Date: Fri, 14 Jul 2006 14:57:23 -0500
Ed Morton wrote:
kevin_m wrote:
Thanks for the reply,
You're welcome, but please don't top-post. Fixed below.
Ed Morton napísal(a):> I want exactly something like you wrote:
kevin_m wrote:
Hi all,
I'm trying to "echo" some informations in a while loop, in ksh script.
I want to quit (only the while loop), if the user enter some key...
Can anyone help me accomplish this task?
Thanks
It seems like there must be more to your loop than you've told us so
far. Apart from the part about breaking out of the loop, do you want to
just do this:
while [ 1 ]
do
echo "All work and no play makes Jack a dull boy"
done
Or do you want to take some kind of a break (e.g. to read something from
a file or from stdin, or to just do the echo every N seconds, or
something) between the iterations of "echo"s, e.g.:
while [ 1 ]
do
echo "All work and no play makes Jack a dull boy"
sleep 1
done
The answer to that question will determine the solution(s).
Ed.
> while [ 1 ]
> do
> echo "All work and no play makes Jack a dull boy"
> sleep 1
> done
In bash you can specify a timeout value for the read command, so you can do:
resp=""
while [ "$resp" != "q" ]
do
echo "All work and no play makes Jack a dull boy"
read -t 1 resp
done
Regards,
Ed.
And if your read doesn't support a timeout value, see the suggestion in the thread at http://tinyurl.com/kykzu
Ed.
.
- References:
- while loop
- From: kevin_m
- Re: while loop
- From: Ed Morton
- Re: while loop
- From: kevin_m
- Re: while loop
- From: Ed Morton
- while loop
- Prev by Date: Re: while loop
- Next by Date: Re: can someone explain the following sed command?
- Previous by thread: Re: while loop
- Next by thread: Re: while loop
- Index(es):
Relevant Pages
|