|
Programming C, bash, Python, Perl, PHP, Java, you name it. |
|
Thread Tools | Display Modes |
|
|
|||
repeat same command n times
hello,
how do I let unix repeat the same command n times, without having to do it manually? I need this for latex, which gets my page formatting properly only after running it quite e few times. tks |
|
||||
You can use a shell script, something like:
Code:
#!/bin/sh for i in $(jot 10); do echo "Running command for the ${i}nth time" done
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. |
|
||||
We Dutch people are fast!
DutchDaemon's solution will work too, personally I think `my' solution is cleaner, but I guess that's a matter of personal preference.
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. |
|
|||
Cool!
They all work perfectly. I also thought I could simply write the same command in a script many times, but it is a good way to learn something new. Thanks a lot. |
|
||||
Quote:
generally the thought "repeat" and the word "loop" are synonymous, inclusive of the old "I don't want to type this thing X amount of times" factor ;-)
__________________
My Journal Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Last message repeated x times | delboy | FreeBSD General | 6 | 25th June 2009 10:08 AM |
run same command many times with diff args | gosha | Programming | 21 | 30th May 2009 11:51 AM |
How to modify the ls command? | bsdnewbie999 | OpenBSD General | 9 | 16th May 2009 08:20 AM |
Thanked X times in X posts | johnlvs2run | Feedback and Suggestions | 6 | 18th May 2008 01:21 PM |
Daemonforums very slow, times out a lot | Weaseal | Feedback and Suggestions | 15 | 16th May 2008 12:44 AM |