Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Apple Computing Products:
macOS - Operating System
Repeating things in the terminal.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="vansmith" data-source="post: 1338948" data-attributes="member: 71075"><p>Loops are your friend. This following example will print Hello x where x is a number:[code]for x in `seq 1 10`</p><p>do</p><p> echo Hello $x</p><p>done[/code]The output of that is as follows:[code]Hello 1</p><p>Hello 2</p><p>Hello 3</p><p>Hello 4</p><p>Hello 5</p><p>Hello 6</p><p>Hello 7</p><p>Hello 8</p><p>Hello 9</p><p>Hello 10[/code]Change the sequence parameters to <em>1 30</em> and that would happen 30 times. Once you change that, simply replace the echo line with the command you want to execute thirty times. So, for instance:[code]for x in `seq 1 30`</p><p>do</p><p> <your command></p><p>done[/code]Replace <your command> with the command you want executed and you're good to go.</p><p></p><p>Save that as a shell script and simply execute it from the command line:[code]sh <path to script>[/code]</p></blockquote><p></p>
[QUOTE="vansmith, post: 1338948, member: 71075"] Loops are your friend. This following example will print Hello x where x is a number:[code]for x in `seq 1 10` do echo Hello $x done[/code]The output of that is as follows:[code]Hello 1 Hello 2 Hello 3 Hello 4 Hello 5 Hello 6 Hello 7 Hello 8 Hello 9 Hello 10[/code]Change the sequence parameters to [I]1 30[/I] and that would happen 30 times. Once you change that, simply replace the echo line with the command you want to execute thirty times. So, for instance:[code]for x in `seq 1 30` do <your command> done[/code]Replace <your command> with the command you want executed and you're good to go. Save that as a shell script and simply execute it from the command line:[code]sh <path to script>[/code] [/QUOTE]
Verification
Post reply
Forums
Apple Computing Products:
macOS - Operating System
Repeating things in the terminal.
Top