Sei sulla pagina 1di 16

http://steve-parker.org/sh/sh.

shtml

Shell Scripting Tutorial

Steve's Bourne / Bash Scripting Tutorial


http://steve-parker.org/sh/sh.shtml A Bourne Shell Programming/Scripting Tutorial for learning about using the Unix shell.

ersion !."a #p$f% &c' "((( - "(!! Steve Parker. )ail To: steve at steve-parker.org *riginal Available +rom: http://steve-parker.org/sh/sh.shtml ,ast Up$ate$: -(th .une "(!!

&See also the blog at http://nixshell./or$press.com/'

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page ! of 1(

http://steve-parker.org/sh/sh.shtml

Shell Scripting Tutorial

Table of Contents
Steve2s Bourne / Bash Scripting Tutorial..................................................................................................! 3ntro$uction .....................................................................................................................................Philosoph4 ......................................................................................................................................5 A +irst Script ...................................................................................................................................1 ariables - Part 3 ...........................................................................................................................!( 6il$car$s ......................................................................................................................................!5 7scape 8haracters .........................................................................................................................!9 ,oops ............................................................................................................................................!: Test ..............................................................................................................................................."8ase ..............................................................................................................................................."; ariables - Part 33 ..........................................................................................................................-! ariables - Part 333..........................................................................................................................-< 7xternal Programs .........................................................................................................................-9 +unctions .......................................................................................................................................-: 7xit 8o$es......................................................................................................................................<9 =uick >eference ...........................................................................................................................<1 ?ints an$ Tips ...............................................................................................................................<; 7xit 8o$es &revisite$'....................................................................................................................59 Simple 7xpect >eplacement .........................................................................................................9! Trap ...............................................................................................................................................97cho : -n vs. @c...............................................................................................................................95 3nteractive Shell ............................................................................................................................99 7xercises........................................................................................................................................9: A$$ressbook..................................................................................................................................9: Airector4 Traversal........................................................................................................................9; ,inks To *ther >esources ............................................................................................................1(

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page " of 1(

http://steve-parker.org/sh/sh.shtml

Shell Scripting Tutorial

Introduction
Purpose Of This Tutorial

This tutorial is /ritten to help people un$erstan$ some of the basics of shell script programmingB an$ hopefull4 to intro$uce some of the possibilities of simple but po/erful programming available un$er the bourne shell. As suchB it has been /ritten as a basis for one-on-one or group tutorials an$ exercisesB an$ as a reference for subseCuent use.
Getting The Most Recent Version Of This Tutorial

The most recent version of this tutorial is available from: http://steve-parker.org/sh/sh.shtml. Al/a4s check there for the latest cop4.
A Brief istor! of sh

Steve BourneB /rote the Bourne shell /hich appeare$ in the Seventh 7$ition Bell ,abs >esearch version of Unix. )an4 other shells have been /rittenD this particular tutorial concentrates on the Bourne an$ the Bourne Again shells. *ther shells inclu$e the Eorn Shell &ksh'B the 8 Shell &csh'B an$ variations such as tcsh. This tutorial $oes not cover those shells. )a4be a future version /ill cover kshD 3 $o not inten$ to /rite a tutorial for cshB as csh programming is consi$ere$ harmful!.
Audience

This tutorial assumes some prior experienceD namel4:


Use of an interactive Unix shell )inimal programming kno/le$ge - use of variablesB functionsB is useful backgroun$ kno/le$ge Un$erstan$ing of ho/ Unix comman$s are structure$B an$ competence in using some of the more common ones. Programmers of perlB p4thonB 8B PascalB or an4 programming language /ho can ma4be rea$ shell scriptsB but $on2t feel the4 un$erstan$ exactl4 ho/ the4 /ork.

! http://///.faCs.org/faCs/unix-faC/shell/csh-/h4not/
Shell Scripting Tutorial 0 "(((-"(!! Steve Parker http://steve-parker.org/sh/sh.shtml Page - of 1(

http://steve-parker.org/sh/sh.shtml
T!pographical "onventions #sed in This Tutorial

Shell Scripting Tutorial

Significant /or$s /ill be /ritten in italics /hen mentione$ for the first time. 8o$e segments an$ script output /ill be $ispla4e$ as preformatte$ text. 8omman$-line entries /ill be prece$e$ b4 the Aollar sign &F'. 3f 4our prompt is $ifferentB enter the comman$:
PS1="$ " ; export PS1

Then 4our interactions shoul$ match the examples given &such as F ./m4-script.sh belo/'. Script output &such as G?ello 6orl$G belo/' is $ispla4e$ at the start of the line.
$ echo '#!/bin/sh' > my-script.sh $ echo 'echo Hello orl!' >> my-script.sh $ chmo! "## my-script.sh $ ./my-script.sh Hello orl! $

7ntire scripts /ill be surroun$e$ b4 thick horiHontal rules an$ inclu$e a reference /here available to the plain text of the script: first.sh "
#!/bin/sh # $his is % comment! echo Hello orl! # $his is % comment& too!

Iote that to make a file executableB 4ou must set the eJecutable bitB an$ for a shell scriptB the >ea$able bit must also be set:
$ chmo! %'rx (irst.sh

" http://steve-parker.org/sh/eg/first.sh.txt

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page < of 1(

http://steve-parker.org/sh/sh.shtml

Shell Scripting Tutorial

Philosoph!
Shell script programming has a bit of a ba$ press amongst some Unix s4stems a$ministrators. This is normall4 because of one of t/o things:

The spee$ at /hich an interprete$ program /ill run as compare$ to a 8 programB or even an interprete$ Perl program. Since it is eas4 to /rite a simple batch-Kob t4pe shell scriptB there are a lot of poor Cualit4 shell scripts aroun$.

3t is partl4 $ue to this that there is a certain machismo associate$ /ith creating good shell scripts. Scripts /hich can be use$ as 8L3 programsB for exampleB /ithout losing out too much in spee$ to Perl &though both /oul$ lose to 8B in man4 casesB /ere spee$ the onl4 criterion'. There are a number of factors /hich can go into goo$B cleanB CuickB shell scripts. !. The most important criteria must be a clearB rea$able la4out. ". Secon$ is avoi$ing unnecessar4 comman$s. A clear la4out makes the $ifference bet/een a shell script appearing as Gblack magicG an$ one /hich is easil4 maintaine$ an$ un$erstoo$. Mou ma4 be forgiven for thinking that /ith a simple scriptB this is not too significant a problemB but t/o things here are /orth bearing in min$. !. +irstB a simple script /illB more often than anticipate$B gro/ into a largeB complex one. ". Secon$l4B if nobo$4 else can un$erstan$ ho/ it /orksB 4ou /ill be lumbere$ /ith maintaining it 4ourself for the rest of 4our lifeN Something about shell scripts seems to make them particularl4 likel4 to be ba$l4 in$ente$B an$ since the main control structures are if/then/else an$ loopsB in$entation is critical for un$erstan$ing /hat a script $oes. *ne of the maKor /eaknesses in man4 shell scripts is lines such as:
c%t /tmp/my(ile ) *rep "mystrin*"

/hich /oul$ run much faster as:


*rep "mystrin*" /tmp/my(ile

Iot muchB 4ou ma4 consi$erD the *S has to loa$ up the /bin/*rep executableB /hich is a reasonabl4 small 159(( b4tes on m4 s4stemB open a pipe in memor4 for the transferB loa$ an$ run the /bin/c%t executableB /hich is an even smaller ;5": b4tes on m4 s4stemB attach it to the input of the pipeB an$ let it run. *f courseB this kin$ of thing is /hat the *S is there forB an$ it2s normall4 prett4 efficient at $oing it. But if this comman$ /ere in a loop being run man4 times overB the saving of not locating an$ loa$ing the c%t executableB setting up an$ releasing the pipeB can make some $ifferenceB especiall4 inB sa4B a 8L3 environment /here there are enough other factors to slo/ things $o/n /ithout the script itself being

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page 5 of 1(

http://steve-parker.org/sh/sh.shtml

Shell Scripting Tutorial

too much of a hur$le. Some Unices are more efficient than others at /hat the4 call Gbuil$ing up an$ tearing $o/n processesG - ieB loa$ing them upB executing themB an$ clearing them a/a4 again. But ho/ever goo$ 4our flavour of Unix is at $oing thisB it2$ rather not have to $o it at all. As a result of thisB 4ou ma4 hear mention of the Useless Use of 8at A/ar$ &UUo8'B also kno/n in some circles as The A$ard %or The Most Gratuitous #se Of The &ord "at In A Serious Shell Script being ban$ie$ about on the comp.+nix.shell ne/sgroup from time to time. This is purel4 a /a4 of peers keeping each other in checkB an$ making sure that things are $one right. Speaking of /hichB 3 /oul$ like to reccommen$ the comp.os.+nix.shell ne/sgroup to 4ouB although its signal to noise ratio seems to have $ecrease$ in recent 4ears. There are still some real gurus /ho hang out there /ith goo$ a$vice for those of us /ho nee$ to kno/ more &an$ that2s all of usN'. Sharing experiences is the ke4 to all of this - the reason behin$ this tutorial itselfB an$ /e can all learn from an$ contribute to open $iscussions about such issues. 6hich lea$s me nicel4 on to something else: Aon2t ever feel too close to 4our o/n shell scriptsD b4 their natureB the source cannot be close$. 3f 4ou suppl4 a customer /ith a shell scriptB s/he can inspect it Cuite easil4. So 4ou might as /ell accept that it /ill be inspecte$ b4 an4one 4ou pass it toD use this to 4our a$vantage /ith the LP,- - encourage people to give 4ou fee$back an$ bugfixes for freeN

- http://///.gnu.org/cop4left/gpl.html

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page 9 of 1(

http://steve-parker.org/sh/sh.shtml

Shell Scripting Tutorial

A %irst Script
+or our first shell scriptB /e2ll Kust /rite a script /hich sa4s G?ello 6orl$G. 6e /ill then tr4 to get more out of a ?ello 6orl$ program than an4 other tutorial 4ou2ve ever rea$ :-' 8reate a file &first.sh' as follo/s: first.sh <
#!/bin/sh # $his is % comment! echo Hello orl! # $his is % comment& too!

The first line tells Unix that the file is to be execute$ b4 /bin/sh. This is the stan$ar$ location of the Bourne shell on Kust about ever4 Unix s4stem. 3f 4ou2re using LIU/,inuxB /bin/sh is normall4 a s4mbolic link to bash. The secon$ line begins /ith a special s4mbol: #. This marks the line as a commentB an$ it is ignore$ completel4 b4 the shell. The onl4 exception is /hen the very first line of the file starts /ith #! - as ours $oes. This is a special $irective /hich Unix treats speciall4. 3t means that even if 4ou are using cshB kshB or an4thing else as 4our interactive shellB that /hat follo/s shoul$ be interprete$ b4 the Bourne shell. Similarl4B a Perl script ma4 start /ith the line #!/+sr/bin/perl to tell 4our interactive shell that the program /hich follo/s shoul$ be execute$ b4 perl. +or Bourne shell programmingB /e shall stick to #!/bin/sh. The thir$ line runs a comman$: echoB /ith t/o parametersB or arguments - the first is G?elloGD the secon$ is G6orl$G. Iote that echo /ill automaticall4 put a single space bet/een its parameters. The # s4mbol still marks a commentD the O an$ an4thing follo/ing it is ignore$ b4 the shell. no/ run chmo! "## (irst.sh to make the text file executableB an$ run ./(irst.sh.

Mour screen shoul$ then look like this:


$ chmo! "## (irst.sh $ ./(irst.sh Hello orl! $ < http://steve-parker.org/sh/eg/first.sh.txt

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page 1 of 1(

http://steve-parker.org/sh/sh.shtml Mou /ill probabl4 have expecte$ thatN Mou coul$ even Kust run:
$ echo Hello Hello orl! $ orl!

Shell Scripting Tutorial

Io/ let2s make a fe/ changes. +irstB note that echo puts *I7 space bet/een its parameters. Put a fe/ spaces bet/een G?elloG an$ G6orl$G. 6hat $o 4ou expect the output to beP 6hat about putting a TAB character bet/een themP As al/a4s /ith shell programmingB tr4 it an$ see. The output is exactl4 the sameN 6e are calling the echo program /ith t/o argumentsD it $oesn2t care an4 more than cp $oes about the gaps in bet/een them. Io/ mo$if4 the co$e again:
#!/bin/sh # $his is % comment! echo "Hello orl!" # $his is % comment& too!

This time it /orks. Mou probabl4 expecte$ thatB tooB if 4ou have experience of other programming languages. But the ke4 to un$erstan$ing /hat is going on /ith more complex comman$ an$ shell scriptB is to un$erstan$ an$ be able to explain: 6?MP echo has no/ been calle$ /ith Kust *I7 argument - the string G?ello 6orl$G. 3t prints this out exactl4. The point to un$erstan$ here is that the shell parses the arguments B7+*>7 passing them on to the program being calle$. 3n this caseB it strips the Cuotes but passes the string as one argument. As a final exampleB t4pe in the follo/ing script. Tr4 to pre$ict the outcome before 4ou run it:

first".sh 5
#!/bin/sh # $his is % comment! echo "Hello orl!" echo "Hello orl!" echo "Hello , orl!" echo Hello , orl! echo Hello orl! echo "Hello" orl! echo Hello " " orl! echo "Hello -",-" orl!" echo .hello. /orl! echo 'hello' /orl! 5 http://steve-parker.org/sh/eg/first".sh.txt # $his is % comment& too!

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page : of 1(

http://steve-parker.org/sh/sh.shtml

Shell Scripting Tutorial

3s ever4thing as 4ou expecte$P 3f notB $on2t /orr4N These are Kust some of the things /e /ill be covering in this tutorial ... an$ 4esB /e /ill be using more po/erful comman$s than echoN

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page ; of 1(

http://steve-parker.org/sh/sh.shtml

Shell Scripting Tutorial

Varia'les ( Part I
.ust about ever4 programming language in existence has the concept of variables - a s4mbolic name for a chunk of memor4 to /hich /e can assign valuesB rea$ an$ manipulate its contents. The bourne shell is no exceptionB an$ this section intro$uces i$ea. This is taken further in ariables - Part 33 /hich looks into variables /hich are set for us b4 the environment. ,et2s look back at our first ?ello 6orl$ example. This coul$ be $one using variables &though it2s such a simple example that it $oesn2t reall4 /arrant itN' Iote that there must be no spaces aroun$ the GQG sign: 012=3%l+e /orksD 012 = 3%l+e $oesn2t /ork. 3n the first caseB the shell sees the GQG s4mbol an$ treats the comman$ as a variable assignment. 3n the secon$ caseB the shell assumes that A> must be the name of a comman$ an$ tries to execute it. 3f 4ou think about itB this makes sense - ho/ else coul$ 4ou tell it to run the comman$ A> /ith its first argument being GQG an$ its secon$ argument being GvalueGP 7nter the follo/ing co$e into var!.sh: var.sh 9
#!/bin/sh 45647SS187="Hello echo $45647SS187 orl!"

This assigns the string G?ello 6orl$G to the variable 45647SS187 then echoes out the value of the variable. Iote that /e nee$ the Cuotes aroun$ the string ?ello 6orl$. 6hereas /e coul$ get a/a4 /ith echo Hello orl! because echo /ill take an4 number of parametersB a variable can onl4 hol$ one valueB so a string /ith spaces must be Cuote$ to that the shell kno/s to treat it all as one. *ther/iseB the shell /ill tr4 to execute the comman$ orl! after assigning 45647SS187=Hello The shell $oes not care about t4pes of variablesD the4 ma4 store stringsB integersB real numbers an4thing 4ou like. People use$ to Perl ma4 be Cuite happ4 /ith thisD if 4ou2ve gro/n up /ith 8B PascalB or /orse 4et A$aB this ma4 seem Cuite strange.

9 http://steve-parker.org/sh/eg/var.sh.txt

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page !( of 1(

http://steve-parker.org/sh/sh.shtml

Shell Scripting Tutorial

3n truthB these are all store$ as stringsB but routines /hich expect a number can treat them as such. 3f 4ou assign a string to a variable then tr4 to a$$ ! to itB 4ou /ill not get a/a4 /ith it:
$ x="hello" $ y=.expr $x ' 1. expr9 non-n+meric %r*+ment $

Since the external program expr onl4 expects numbers. But there is no s4ntactic $ifference bet/een:
45647SS187="Hello orl!" 456SH:2$647SS187=hi 456;<4=72=1 456P>=?.1@A 456:$H726P>="?.1@A" 4564>B7C=1A?%bc

Iote though that special characters must be properl4 escape$ to avoi$ interpretation b4 the shell. This is $iscusse$ further in 7scape 8haracters. 6e can interactivel4 set variable names using the re%! comman$D the follo/ing script asks 4ou for 4our name then greets 4ou personall4: var".sh 1
#!/bin/sh echo h%t is yo+r n%meD re%! 456;147 echo "Hello $456;147 - hope yo+'re /ell."

3 ha$ originall4 misse$ out the $ouble-Cuotes in line -B /hich meant that the single-Cuote in the /or$ G4ou2reG /as unmatche$B causing an error. 3t is this kin$ of thing /hich can $rive a shell programmer craH4B so /atch out for themN This is using the shell-builtin comman$ re%! /hich rea$s a line from stan$ar$ input into the variable supplie$. Iote that even if 4ou give it 4our full name an$ $on2t use $ouble Cuotes aroun$ the echo comman$B it still outputs correctl4. ?o/ is this $oneP 6ith the 45647SS187 variable earlier /e ha$ to put $ouble Cuotes aroun$ it to set it. 6hat happensB is that the re%! comman$ automaticall4 places Cuotes aroun$ its inputB so that spaces are treate$ correctl4. &Mou /ill nee$ to Cuote the outputB of course - e.g. echo "$45647SS187"'.

1 http://steve-parker.org/sh/eg/var".sh.txt

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page !! of 1(

http://steve-parker.org/sh/sh.shtml Scope of Varia'les

Shell Scripting Tutorial

ariables in the bourne shell $o not have to be $eclare$B as the4 $o in languages like 8. But if 4ou tr4 to rea$ an un$eclare$ varableB the result is the empt4 string. Mou get no /arnings or errors. This can cause some subtle bugs - if 4ou assign 456:=E<SF1$7C6012>1=G7=Hello an$ then echo $456:SE<F1$7C6012>1=G7B 4ou /ill get nothing &as the secon$ *B+US8AT7A is mis-spelle$'. There is a comman$ calle$ export /hich has a fun$amental effect on the scope of variables. 3n or$er to reall4 kno/ /hat2s going on /ith 4our variablesB 4ou /ill nee$ to un$erstan$ something about ho/ this is use$. 8reate a small shell scriptB my3%rA.sh: m4var".sh :
#!/bin/sh echo "45012 is9 $45012" 45012="hi there" echo "45012 is9 $45012"

Io/ run the script:


$ ./my3%rA.sh 45012 is9 45012 is9 hi there

)M A> hasn2t been set to an4 valueB so it2s blank. Then /e give it a valueB an$ it has the expecte$ result. Io/ run:
$ 45012=hello $ ./my3%rA.sh 45012 is9 45012 is9 hi there

: http://steve-parker.org/sh/eg/m4var".sh.txt

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page !" of 1(

http://steve-parker.org/sh/sh.shtml

Shell Scripting Tutorial

3t2s still not been setN 6hat2s going onPN 6hen 4ou call my3%rA.sh from 4our interactive shellB a ne/ shell is spa/ne$ to run the script. This is partl4 because of the #!/bin/sh line at the start of the scriptB /hich /e $iscusse$ earlier. 6e nee$ to export the variable for it to be inherite$ b4 another program - inclu$ing a shell script. T4pe:
$ export 45012 $ ./my3%rA.sh 45012 is9 hello 45012 is9 hi there

Io/ look at line - of the script: this is changing the value of 45012. But there is no /a4 that this /ill be passe$ back to 4our interactive shell. Tr4 rea$ing the value of 45012:
$ echo $45012 hello $

*nce the shell script exitsB its environment is $estro4e$. But 45012 keeps its value of hello /ithin 4our interactive shell. 3n or$er to receive environment changes back from the scriptB /e must source the script - this effectivel4 runs the script /ithin our o/n interactive shellB instea$ of spa/ning another shell to run it. 6e can source a script via the G.G comman$:
$ 45012=hello $ echo $45012 hello $ . ./my3%rA.sh 45012 is9 hello 45012 is9 hi there $ echo $45012 hi there

The change has no/ ma$e it out into our shell againN This is ho/ 4our .pro(ile or .b%sh6pro(ile file /orksB for example. Iote that in this caseB /e $on2t nee$ to export 45012. Thanks to sway for pointing out that 32$ originall4 sai$ echo 45012 aboveB not echo $45012 as it shoul$ be.

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page !- of 1(

http://steve-parker.org/sh/sh.shtml

Shell Scripting Tutorial

*ne other thing /orth mentioning at this point about variablesB is to consi$er the follo/ing shell script:
#!/bin/sh echo " h%t is yo+r n%meD" re%! <S726;147 echo "Hello $<S726;147" echo "> /ill cre%te yo+ % (ile c%lle! $<S726;1476(ile" to+ch $<S726;1476(ile

Think about /hat result 4ou /oul$ expect. +or exampleB if 4ou enter GsteveG as 4our US7>RIA)7B shoul$ the script create ste3e6(ileP Actuall4B no. This /ill cause an error unless there is a variable calle$ <S726;1476(ile. The shell $oes not kno/ /here the variable en$s an$ the rest starts. ?o/ can /e $efine thisP The ans/er isB that /e enclose the variable itself in curl4 brackets: user.sh ;
#!/bin/sh echo " h%t is yo+r n%meD" re%! <S726;147 echo "Hello $<S726;147" echo "> /ill cre%te yo+ % (ile c%lle! $H<S726;147I6(ile" to+ch "$H<S726;147I6(ile"

The shell no/ kno/s that /e are referring to the variable <S726;147 an$ that /e /ant it suffixe$ /ith 6(ile. This can be the $o/nfall of man4 a ne/ shell script programmerB as the source of the problem can be $ifficult to track $o/n. Also note the Cuotes aroun$ "$H<S726;147I6(ile" - if the user entere$ GSteve ParkerG &note the space' then /ithout the CuotesB the arguments passe$ to to+ch /oul$ be Ste3e an$ P%rJer6(ile - that isB /e2$ effectivel4 be sa4ing to+ch Ste3e P%rJer6(ileB /hich is t/o files to be to+che$B not one. The Cuotes avoi$ this. Thanks to 8hris for highlighting this.

; http://steve-parker.org/sh/eg/user.sh.txt

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page !< of 1(

http://steve-parker.org/sh/sh.shtml

Shell Scripting Tutorial

That's all for the sa)ple of the tutorial* Please visit http+//steve(par,er*org/sh/sh*sht)l for the full P-% docu)ent. and for the full online tutorial*

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page !5 of 1(

http://steve-parker.org/sh/sh.shtml

Shell Scripting Tutorial

/in,s To Other Resources


http://steve-parker.org/sh/bourne.shtml- Steve Bourne2s 3ntro$uction to the Unix Shell. http://///.iki.fi/era/unix/: ?istor4B Useless Use *f ... A/ar$sB etc http://///.mpi-sb.mpg.$e/Su/e/lehre/unixffb/Cuoting-gui$e.html - a prett4 $efinitive $ocument on Cuoting an$ escape characters. http://///.linux.com/archive/fee$/-<95: T 6hat to /atch out for /hen /riting portable shell scripts http://bhami.com/rosetta.html - the >osetta Stone for Unix

The Printed Boo,


Publishe$ b4 6rox an$ coming out /orl$/i$e in August "(!!B the book Shell Scripting: Expert Recipes for Linux, Bash and more is available from all goo$ retailers. 3SBI !!!:("<<:9. >>P F<;.;;. http://steve-parker.org/book/ has the $etailsD from August "(!! the book /ill be available to bu4 online an$ in stores.
Part I ( /anguage and #sage 8hapter ! ?istor4 8hatper " Letting Starte$ 8hapter ariables 8hapter < 6il$car$ 7xpansion 8hapter 5 8on$itional 7xecution 8hapter 9 ,oops 8hapter 1 ariables 8ontinue$ 8hapter : +unctions an$ ,ibraries 8hapter ; Arra4s 8hapter !( Processes 8hapter !! 8hoosing an$ Using Shells Part II ( Recipes using S!ste) Tools 8hapter !" +ile 8ontrol 8hapter !- Text )anipulation 8hapter !< S4stems A$ministration Part III ( Recipes for S!ste)s Ad)inistration 8hapter !5 Shell +eatures 8hapter !9 S4stems A$ministration 8hapter !1 Presentation 8hapter !: Aata Storage an$ >etrieval 8hapter !; Iumbers an$ )ath 8hapter "( Process 8ontrol 8hapter "! 3nternationaliHation

Shell Scripting Tutorial 0 "(((-"(!! Steve Parker

http://steve-parker.org/sh/sh.shtml

Page !9 of 1(

Potrebbero piacerti anche