Language sh
(simple sh example with 1 function)
Date: | 12/07/07 |
Author: | Rob Franken |
URL: | n/a |
Comments: | 2 |
Info: | n/a |
Score: | (4.25 in 4 votes) |
#!/bin/sh #The real sh not with bash extensions #for testing use dash as interpreter because sh is often simlinked to bash bottles(){ if test $1 -eq 1 then echo 1 bottle elif test $1 -eq 0 then echo no more bottles else echo $1 bottles fi } i=99 until test $i -eq 0 do echo `bottles $i` of beer standing on the wall, `bottles $i` of beer. i=$(($i-1)) echo Take one down and pass it around, `bottles $i` of beer on the wall. echo done echo No more bottles of beer standing on the wall, `bottles 0` of beer. echo Go to the store and buy some more, `bottles 99` of beer on the wall.
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
Sve@r said on 07/05/08 11:06:56
Calling two times function "bottle" !!! Can't you memorize result in var ???
Rob Franken said on 05/31/09 22:20:03
i could do that, didn't think of it while i made this code