Recent Changes - Search:

Softwares

.

WhileLoopExample

Main.WhileLoopExample History

Hide minor edits - Show changes to output

July 20, 2007, at 10:56 AM by 61.17.224.18 -
Changed lines 33-35 from:

to:
The script in bash -x mode

]$ bash -x while_loop
+ true
++ date +%s
+ touch PIC-1184928926.jpg
+ sleep 10
+ true
++ date +%s
+ touch PIC-1184928936.jpg
+ sleep 10




----
July 20, 2007, at 10:54 AM by 61.17.224.18 -
Changed lines 22-23 from:
to:
----

*The true control statement will execute the script below until CTRL+C is pressed or the script is killed.

#!/bin/bash
while true;
do
touch PIC-`date +%s`.jpg
sleep 10
done

July 20, 2007, at 10:27 AM by 61.17.224.18 -
Added lines 22-24:


Reference: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html
July 20, 2007, at 10:13 AM by 61.17.224.18 -
Added lines 1-22:
* While loop syantax:

while control-commands;
do

other-commands;

done

Example:

$ cat while_loop
#!/bin/bash
i="0"
while [ $i -lt 4 ]
do
echo "this is whole loop $i"
i=$[$i +1]
sleep 10
done

Edit - History - Print - Recent Changes - Search
Page last modified on July 20, 2007, at 10:56 AM