bash script to run program N times

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • khoda
    New Member
    • Sep 2009
    • 6

    bash script to run program N times

    wasn't sure what forum to put this in, but I'm sure someone here can help me.

    I have a program that I want to run N times. I'd like to make a bash script that, when run like this:

    ./script.sh 5

    will run my program 5 times, where my program can be run like this:

    ./myprogram

    Basically I just need a loop that will execute my program, then iterate when the execution exits.

    Any tips?
  • sumittyagi
    Recognized Expert New Member
    • Mar 2007
    • 202

    #2
    use for loop construct, or while loop construct.. whichever you like.

    Google -> using loops in shell script

    Hope this helps

    Best Regards,
    Sumit.

    Comment

    • vl4kn0
      New Member
      • Feb 2009
      • 5

      #3
      Code:
      #!/bin/bash
      
      for i in `seq 1 $1`; do
              ./myprogram
      done

      Comment

      Working...