BashScripting

From S23Wiki
Jump to: navigation, search

Scripts for the 'Bourne Again Shell'. (mostly running under Linux and BSD).


#/bin/bash

while [ hosting_party ]
do
    case $FOOD_STATUS
    in
        potato_chips_gone) replace_potato_chips;;
        peanuts_finished) refill_peanut_bowl;;
        pretzels_gone) open_new_pretzel_bag;;
        ...
        ...
    esac
 

    if [ police_on_scene ]
    then
        talk_to_nice_officers
        continue
    fi

    case $LIQUOR_STATUS
    in
        vodka_gone) open_new_vodka_bottle;;
        rum_gone) open_new_rum_bottle;;
        ...
        ...
    esac

    case $ANALYZE_GUEST_BEHAVIOR
    in
        lampshade_on_head)     echo "He's been drinking";;
        talking_to_plants)     echo "She's been smoking";;
        talking_to_martians)   echo "They're doing LSD";;
        levitating_objects)    echo "Who spiked my lemonade??";;

    ...

    ...

    ...

    esac

done

echo "Dude... what day is it?" 

taken from: http://www.linuxgazette.com/issue53/okopnik.html

let planets=19200; let myp=7;percent=`echo $myp/$planets | bc -l`;echo "w00t! you own $percent percent of all dg planets"


also see Bash Scripts