Don't want be offensive, but if you can write a "generalized" program all you need is learn th syntax of the while
, if
for bash and read the man pages of the grep
and kill
and so on...
And the pipes
are the same as in your garden. Having two things: tap
and pond
. You can fill your pond with many ways (e.g. with rain). Also, you can open your tap getting water. But if you want fill the pond with the water from a tap, need a pipe. That's all. Syntax:
tap | pond
- the output from a tap
- connect with a pipe
- to the (input) of the pond
e.g.
netstat | grep
- the output from a
netstat
- connect with a pipe
- to the input of the
grep
that's all magic... :)
About the syntax: You tagged your question as bash
.
So googling for a bash while syntax
will show to you, this Beginners Bash guide
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html
to, and you can read about the if
in the same website.
Simply can't believe than after 3 hours you cannot understand basic while
and if
syntax to write your program with a bash syntax - especially, when you able write an "generalized" program...
is is not to hard (with modifying the 1st example in the above page) to write:
THRESHOLD="0"
while [ $THRESHOLD -lt 10 ]
do
#do the IF here
THRESHOLD=$[$THRESHOLD+1]
done
and so on...