bash for loop

Here’s a simple shell trick that does a loop through some numbers:

for i in {0..10}; do echo $i; done

For example, sometimes you want to test some concurrent read/write performance on database or whatever, you can do:

for i in {1..10}; do (echo $i; ./read_db.sh $i &); done

This will generate 10 processes that execute the read_db.sh script concurrently.

This entry was posted in shell magic and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>