Language BASH
(Self Writing)
| Date: | 07/18/12 |
| Author: | Olosta |
| URL: | n/a |
| Comments: | 0 |
| Info: | n/a |
| Score: |
#!/bin/bash # Clean up previous run f=$(mktemp scriptXXXX.sh) head -n 31 $0 > $f cp -f $f $0 rm $f # Print verse bottle=99 if [ $bottle == 1 ] ; then str="One bottle" elif [ $bottle == 0 ] ; then str="No more bottles" else str="$bottle bottles" fi echo "$str of beer on the wall," echo "$str of beer," if [ $bottle == 0 ]; then echo "Go to the shop and buy some more." exit else echo "take one down, pass it around." fi # Copy beginning of the file at the end f=$(mktemp scriptXXXX.sh) cp -f $0 $f echo "bottle=$((bottle - 1 ))" >> $f head -n 30 $0 | tail -n +9 >> $f cp -f $f $0 rm $f # New code will go bellow this line
Download Source | Write Comment
Alternative Versions
| Version | Author | Date | Comments | Rate |
|---|---|---|---|---|
| Bourne Again Shell | Dave Plonka | 04/20/05 | 5 | |
| No loop, no recursion | Frédéric Lang | 07/08/08 | 3 | |
| portable, rich of features, readable | Bastian Bittorf | 08/20/07 | 0 | |
| with arrays and functions | Vittorio Cagnetta | 06/30/06 | 0 | |
| Arithmetic on English words for numbers | Bill Brown | 07/31/08 | 0 | |
| recursive function | Koen Noens | 12/30/07 | 0 |
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