View Single Post
  #2   (View Single Post)  
Old 10th March 2009
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Real Name: Ben
Spam Refugee
 
Join Date: Jul 2008
Location: Rotterdam, The Netherlands
Posts: 336
Default

Code:
num=0; while [ $num -le 10 ]; do some_command; num=$(expr $num + 1); sleep 2; done
Will run some_command ten times with 2 second intervals.

In a script named 'run':

Code:
num=0; while [ $num -le $1 ]; do $2; num=$(expr $num + 1); sleep 2; done
Call as 'run 10 ls' or 'run 3 "ps ax"' (commands containing a space must be quoted to be seen as one argument).

Mind you, if it's always the exact same command you have to run five times, you can just put the command in a shell script 5 times and run the shell script

Last edited by DutchDaemon; 10th March 2009 at 03:33 PM.
Reply With Quote