Foxtrot Posted February 20, 2013 Share Posted February 20, 2013 Hey guys, Was wondering if their was a way to repeat commands automagically from bash. For example if for what ever reason I want to issue echo "Hello World!" infinite times, how would I go about doing that? Cheers, -Foxtrot Quote Link to comment Share on other sites More sharing options...
BlueWyvern Posted February 20, 2013 Share Posted February 20, 2013 (edited) im not sure about infinite, but you can make it quite a few with a for loop This *SHOULD* do the trick for you, just set the ending number to something unfathomable 0 is your starting number, 1000000 is your ending number, 1 is your iteration #!/bin/bash for i in {0..1000000..1} do echo "Hello World" done OR (This would be infinite, but not 100% certain if it would work right) lol #!/bin/bash while [ 1=1 ] do echo "Hello World!" done Edited February 20, 2013 by BlueWyvern Quote Link to comment Share on other sites More sharing options...
Jason Cooper Posted February 20, 2013 Share Posted February 20, 2013 You can also used while true in place of while [1=1] Logically the same but a little easier to read. Quote Link to comment Share on other sites More sharing options...
Foxtrot Posted February 20, 2013 Author Share Posted February 20, 2013 Thanks! #!/bin/bash while [ 1=1 ] do echo "Hello World!" done did the trick! Thanks again, -Foxtrot Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.