Linux Today: Linux News On Internet Time.

Bash Tricks I: (very) Repetitive tasks

Feb 18, 2009, 09:04 (0 Talkback[s])
(Other stories by Edmundo Carmona)

[ Thanks to Edmundo Carmona for this link. ]

"Repetitive tasks
Sometimes, you might want to repeat a task a number of times. For example, right now I want to find out which one is faster on PHP: Using variables or defining constants

"I have two script where I define a constant/variable (depending on the script) and I write its value to stdout. Let's say I want to run the variable.php script 1000 times. What I do is:

"i=0; while [ $i -lt 1000 ]; do php variable.php > /dev/null; i=$(( $i + 1 )); done

"But what does all that stuff mean? Let's decompose it:"

Complete Story

Related Stories: