Linux Today: Linux News On Internet Time.

More on LinuxToday

Teach an Old Shell New Tricks With BashDiff

Oct 29, 2008, 07:31 (0 Talkback[s])
(Other stories by Ben Martin)

"BashDiff extends the for, while, and until commands to include optional then and else blocks following the main loop block. These new optional then/else blocks let you perform an action after a normal iteration of the block (the then block) and a block of commands when the break command is used (the else block). Using the else block is useful if you want to see if the loop was terminated early using the break command.

"Bash 3 includes the sequence generation expression {1..100}, which expands to a space-separated sequence of the numbers between 1 and 100. In standard bash you cannot set these minimum and maximum values using shell variables but must fall back to using the seq command. BashDiff allows you to use variables, as the following example shows:"

Complete Story

Related Stories: