[ Pobierz całość w formacie PDF ]
.If it finds amatch, itwill execute the appropriate <commandlist>. More than onepattern can beincluded per line by separating them with a pipe (|) symbol. Also, you can use the pattern * to include everything else.Examplescript: -------- #!/bin/bash case $1 in cheese | bread | meat) echo "food!" ;; viper | stingray | transam) echo "car!" ;; *) echo "I don't know what it is!" ;; esac --------- This is fairly straight forward once you get to gripswith it.It pullsin a parameter that you enter on the command line and tries to figureoutwhat it is.If you enter "cheese", "bread" or "meat", our clever scriptwillrecognize this as a type of food and will tell you so. If you enter "viper", "stingray" or "transam", itwill recognize it as acar! Anything else leaves our poor program clueless. There is also a command called select which was stolenfrom the kornshell.The syntax for this is very similar to case.See if you canfigure itout and get it working.HINT - read "man bash". There are many more features of bash, I have notcovered a greatportion, but that is part of the fun.Now go read the man page (thistextshould help you make sense out of it!) and see what other nifty littlefeatures bash has. I wrote this tutorial using bash version 1.14.7(1).I am aboutto upgradeto 2.02.01 or whatever the latest is to see what differences that givesme. Get the latest bash version via ftp at prep.ai.mit.eduor one of itsmirror sites.This is a good time to brush up your search engine skills;)_______________________________________________________________________Where are those back issues of GTMHHs and Happy Hacker Digests? Checkoutthe official Happy Hacker Web page at http://www.happyhacker.org.We are against computer crime.We support good, old-fashioned hackingof thekind that led to the creation of the Internet and a new era of freedomofinformation.So don't email us about any crimes you may have committed!To subscribe to Happy Hacker and receive the Guides to (mostly) HarmlessHacking, please email hacker@techbroker.comwith message "subscribehappy-hacker" in the body of your message.Copyright 1998 idle (idle@mailexcite.com).You may forward, print out orpost this GUIDE TO (mostly) HARMLESS HACKING on your Web site as longas youleave this notice at the end._________________________________________________________Carolyn MeinelM/B Research -- The Technology Brokershttp://techbroker.com
[ Pobierz całość w formacie PDF ]