; TeX output 2003.04.04:1550Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdFf color pop㖍ۺ^jhtml: html:html: html:DǍ[DM% aessbx10Unix `shellscripting!CԁDM%G aessbx10DanielSC.vonAsmuth#lInhoudsopgave color push gray 0html: Ս  1 ecrm10001.U Unixendeshell html: color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push gray 0html:1 html: color popffcolor push gray 0html: 2.U elementairshellprogrammeren html: color popTcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push gray 0html:6 html: color popXcolor push gray 0html: X 3.U enkeleUnixtoGols html: color pop`color push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color popcolor push Black. color pop-6color push gray 0html:18 html: color pophtml: html:html: html: DitKiseenuitgebreideinleidingoverKhetgebruikvqandehtml: html:UnixshellenbijbGehorendehulpmiddelenomscriptste schrijven.JHetverondersteltenigekennisvqandehtml: html:Unixcommandoregel,bijvoGorbeeldJdebash-prompt-howto.Het bGevqatU watmeervoGorbeeldenU dandeocilehandleidingen.@html: html:'DM%ff aessbx101.E/Unixendeshell33html: html: De6shellisdehtml: html:Unix`commandostip',dieopGdrachten6vqandegebruikersinleestvanhettoGetsenbord,6zeuitvoGerten hetresultaatophetschermzet.IndesimpGelstevormbGestaateenopdrachtuitdenaamvqaneenprogramma;de shell#{zaldatprogrammadanopstarten,datdebGeschikkingoverhettoGetsenbord#{enbGeeldschermkrijgt,enlaateen nieuweU promptzienalshetprogrammabGeindigdis.html: html: X HetGhtml: html:UnixbGesturingssysteemwordtweleensvoGorgesteldalsbestaandeuiteenhardekernoftewelkernel,diede hardwareaanstuurtenhardwareaanstuurtendatdeshelleenschileromheenis,diedekernelvqandegebruikers afschermt.rHetisechterrdetaakvqandekernelomdehardwareafteschermen,terwijldeshelldientomtoGegangtot hetsysteemtegeven.Gebruikersprogramma'shoGevengeengebruikvqandeshelltemaken;deC-bibliotheekheeft bijvoGorbeeldU weldefunctievqaneenschilomdekernel.html: html: DM% aessbx101.1.dRinleidingShtml: html: Dit@verhaalgaatervqanuitdatuenigeervaringmethtml: html:UnixhebtendusmethettypGenvancommando'sindeshell. HetzkqannoGoitkwaadomdeuitgebreideinformatieovereenbGesprokencommandooptevragenmethtml: html:mancommando ofU (ophtml: html:GNUsystemen)html: html:infocommando.html: html: ( Er>zijnverschillende>vqariantenophethtml: html:UnixbGesturingssysteem;allebesturingssystemendiedehierbesprokencom- mando's"bGezittenwordenhiervoGorhetgemakmethtml: html:Unixaangeduid,ookalzijnzenietgebaseerdopdeoriginele coGdeBvqanhtml: html:ABT&BT.Opeenhtml: html:UnixsysteemzijnvaakverschillendeBshellstevinden.HetisoGokmogelijkomeenshell te?draaienopWindowshtml: html:NT9 tcrm1000€.DevoGorbeelden?bijditverhaalzijngetestonderLinuxenzullenopanderesystemen somsU aanpassingbGehoeven.html: html: X De%,oGorspronkelijkehtml: html:ck aett9/bin/shisdeBourneshell,endeanderezijndaarvqanafgeleid.DenummertweewasdeC-shell, diehandigefeatureshadomproGcessentebesturen,maarminderhandigomermeeteprogrammeren,endusniet verder@aandeordezalkomen.DenieuwereKornshelllijktweermeeropdeBourneshell,metdefeaturesvqande C-shell,spluseenhelereekseigenuitbreidingenvoGorinteraktiefgebruikenprogrammeren.DeBourneAgainShell vqanU hethtml: html:GNUpro0jektheefteveneenseenwijdeverbreidinggekregen.html: html:! 1.2.dRMijneerstescriptjeShtml: html: Het=bijzondereaandeshellisdathijzowel=eenhandigecommandoverwerker=isvoGorinteraktiefgebruikalseenpro- grammeertaal.wV*erschillendedelenvqaneenhtml: html:UnixbGesturingssysteembestaanuitshellscripts,omdatdezegemakkelijk0ۺcolor push BlackF1Ff color pop*Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjdoGordegebruikeraandiensbehoeftekunnenwordenaangepast,watvoGoralsysteembGeheerderswaarderen.Shell scriptsU wordenoGokvqaakgebruiktalseenschilomeencomplexeapplicatie.ۺhtml: html: X HetiseenkleinemoGeiteomeenkortereeksveelgebruiktecommando'ssamentevoGegentoteenscriptje:maakmet html: html:viU (c.q.uwfavorieteeditor)eenlehtml: html:voorbeeldaanmetdevolgende,vrijwillekeurige,inhoud:@html: html:html: html: 3[ date 3 unameG-a who V*ervolgensstyptuhtml: html:chmoGdugo+rxvoGorbeeld>waarmeehettekstbestandtotprogrammawordtgepromoveerd,dat met9html: html:./voGorbeeldshkqan9wordenuitgevoGerd.DekerneliszelfinstaattebGepalenofeenuittevoGerenleeenscriptof binairU programmabGevqat.html: html: X InhetvoGorbeeldisdedirectorywaarhetprogrammazichbGevindtexplicietopgegeven.Alsdiewordtweggelaten zalodeshelldelijstvqandirectory'sdoGorzoekenodieindespGecialevariabGelehtml: html:$P*ATHYstaat.oHetisenigszinsriskantom deU aktueledirectory(html: html:.)inhetzoGekpadoptenemen.html: html: ( Eenstandaardvergissingisomeigenprogramma'sdenaamhtml: html:testtegeven.Helaasishtml: html:testeeningebGouwdcommando vqan+deshell.Deshellheeftnietzoveel+ingebGouwdecommando's:hetmeestewerkwordtdoGorexterneprogramma's gedaan.html: html:! 1.3.dRhallohtml: html: AlsPvolgendevoGorbeeldPdenederlandstaligeversievqanhetonvermijdelijkenuttelozeprogrammahtml: html:hello,bGekendvqan KernighanU &Ritchie.@html: html:html: html: #!/bin/sh 3 #Gditprogrammazegtvriendelijkgoedendag echoGHallo,allemaal!;exit0 Dit[8lijktalietsmeeropeenprogramma.Indeeersteregelstaatachter[8html: html:#!aangegevenwelkprogrammahetscript moGetauitvoeren.Normaliterisdatdeshellwaarmeeuinlogt;ukunthiermeevoGorkomendateenprogramma nietʺwerktalshetbijvoGorbeeldʺvqanafdeC-shellwordtgestart.AandeanderekqantzaleenscriptdatbGegintmet html: html:#!/bin/bashnietwerkenopeensysteemwaardieshellinhtml: html:/usr/local/binstaatofafwezigis.Dezeeigenschapis voGoralU handigvoGorscriptsinanderetalen,bijv.:@html: html:html: html: #!/usr/bin/perl 3 printG"Hallo,allemaal!\n" Deprogrammeertaalhtml: html:PerlwordthiernietverderbGehandeld.V*oorderestgeefteenhekjeaandatderestvqanderegel kommentaaris.EenlegecommandoregelistoGegestaan.BehalveheteindevqanderegelkanoGokeenpuntkomma wordenU gebruiktomopGdrachtentescheidendienaelkqaarwordenuitgevoGerd.html: html: X DeopGdrachthtml: html:echoiseeningebGouwdefunctievqandeshell,netalstrouwensexit.html: html:EchozorgtervoGordatderesterende woGordenophethtml: html:standaarduitvoGerkqanaal(bijv.hetscherm)wordenafgedrukt.Shellcommando's,argumentenen vlaggenU moGetenatlijdvqanelkaarwordengescheidendoGorspatiesofanderescheidingstekens.html: html: X DeSopGdrachthtml: html:exitbGeindigthetscript,ookalsernogopdrachtenvolgen;hetgebruikervqanisnietverplicht.Net als(deexitfunctieineenC'programmawordtereenfoutcoGdegeretourneerd,die0bedraagtalsergeenfoutis opgetreden.U Typmaareensdevolgenderegelsinachterdeprompt.@html: html:html: html: true 3 echoG$?0ۺcolor push BlackF2Ff color popLޠОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjfalse 3echoG$?DevqariabGelehtml: html:$?krijgtdehtml: html:exitstatusvanhetlaatstuitgevoGerdecommandoofscript.Naexitofheteindevaneen scriptEgaatdeshellverdermethetaanroGependeEscriptofvraagtdegebruikerominvoGer.html: html:T*rueenhtml: html:falsezijnexterneprogramma'svdienietsdoGenenalleeninshellprogramma'snuthebben.HetresultaatverschiltvnogalvqanBooleantypGesU inandereprogrammeertalen.ۺhtml: html: X Als,uinlogtzaldeshelleersthetscripthtml: html:/etc/profileuitvoGeren,waarinzichalgemeneinstellingenbGevinden,gevolgd doGor3html: html:.profileinuweigendirectory*,waarinuuwpGersoonlijke3instellingenkwijtkunt.BashenkshkennenoGok initialisatieleshtml: html:~/.bashrcenhtml: html:~/.kshrcdieiederekeeruitgevoGerdwordenalseeninteractieveshellstart,bijvoGorbeeld bijU hetopGenenvqaneenxterm.html: html:! 1.4.dReenherhalingso\#efeningShtml: html: DerestvqandithoGofdstukwordtbesteedaanhtml: html:Unixendeshell,zonderdaterverderprogrammerenbijkomtkijken. DeU bGehandelingzalergoppervlakkigblijven;incolor push gray 0html:Paragraaf3 html: color popkomenweeruitgebreidopterug.html: html: X Het߻centraleconceptinhtml: html:Unixisdehtml: html:leoftewelhetbGestand.FileswordenvoGortdurendgebruiktwaarinformatievoGor minPofmeerlangetijdmoGetwordenbewaard.Eenleiseenreeksbytes,diemeestalopeenschijfwordtbGewaard. DebGelangrijksteoperatieszijnhetlezenofschrijvenvqaneenaantalbytes.Daarbijwordtdehtml: html:lepGointerofbladwijzer omChetaantalgelezenofgeschrevenbytesverplaatst.V*erderishetmogelijkomdelepGointernaareenopgegeven puntU teverplaatsenendelengtevqanhetbGestandintekrimpentotbijvoorbeeldnulbytes.html: html: X DeinhoudvqaneenbGestandligtnietvast.html: html:UnixmaaktvaakgebruikvantekstbGestanden.EenbytestaatdanvoGor een letterteken(kqarakter)vanhethtml: html:ASCIGIalfabet. Hettekenoftewel0xaoftwel^Joftewel\ngeeftheteinde vqaneenregelaan.ErisgeentekennoGdigomheteindevaneenbGestandtemarkeren,maar^Dkanwordengebruikt omU invoGervqandeterminaltebeindigen.html: html: X V*eeltoGolsgaanervqanuitdateenbestandtekstbevqat.Bijvoorbeeldzalhtml: html:catvoorbeelddeinhoudvqanhetbestand overhetschermlatenlopGen.Alshetbestandechtergeentekstbevqat,dankandeterminaldeklutskwijtrakenvan deU stuurcoGdes;doedusgeenhtml: html:/bin/cat/bin/cat.Methtml: html:cat-vlooptugeengevqaar.html: html: ( InsommigeUniceskuntudeschadereparerenmethetcommandohtml: html:reset.DeoudemethoGdeisdeterminaluiten weeraantezetten.DeschadeistevoGorkomen.Hetkommandohtml: html:lehallozouietsmoGetengevenalshtml: html:hallo:GBourne shellGscripttext.whtml: html: Als 2leeenfrasemethetwoGord`executable'erinretourneert,hebbenwetemakenmeteenbinairprogramma.Een binair,programmakunjealleenuitvoGeren:datwerktweleenstuksnellerdaneeningewikkeldshellscript.Filekqan zichU ondankszijn`magic'uiteraardvergissen.html: html: X V*erderzijnerspGecialeles,waarmeebijvoGorbeeldapparatenkunnenwordenafgelezenofbGeschrevenalsofhet leswaren;eentapGewordtbijvoGorbeeldbediendalseenhelelangepseudo-le,waarvqandegrootteaaneenvqast maximumU isgebGonden.Dezewordenvqaakindehtml: html:/devdirectorygevonden.html: html: X T*ekstCkdienaarhtml: html:/dev/ttywordtgeschreven,wordtwelzichtbaargemaakt,maarnietopgeslagen.EenpGogingom html: html:/dev/tty9ٺuittelezenretourneertnietdegeschreven9tekst,maarvqanhettoGetsenbord9ingevoerde9tekens.html: html:Unixzalu latenU wachtentotdatereenregelisingevoGerd,c.q.opdereturn-toetsisgedrukt.html: html: X OmeentekstbGestanduitteprintenzoujehtml: html:cathallo>/dev/lp0ofietsdergelijkskunnendoen,maarhtml: html:Unixstaatdat enkelSaandeuserhtml: html:roGottoe.DejuistemanieromeenbestandteprintenisviahetprinterspGoolprogrammaSmethtml: html:lpr hallohtml: html: EenanderbGestanddatinscriptsgebruiktkqanwordenishtml: html:/dev/null,ookweldebittenbakgenoGemd,omdatalledata die`ernaartoGewordengeschrevendirektwordenweggegoGoidintegenstellingtotdevuilnisbakvqandeMacintosh€. LezenU uithtml: html:/dev/nullistoGegestaan,maarerzalnietsuitkomen.html: html:0ۺcolor push BlackF3Ff color pop`Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjDehtml: html:directory'skunnenwordenbGeschouwdalseenspGeciaalsoortbestand,datalleenmetspecialeopdrachtenals html: html:ls,html: html:cp,html: html:mv,html: html:rmenhtml: html:lnkqanwordengemanipuleerd.Directory'sbGevqattenweinigandersalsdenamenvqanlesendirectory's.-DaaromisvoGoreenopdracht-alshtml: html:rm-f./voorbeeldschrijfpermissieopdeaktueledirectoryvereist,maargeenpGermissieophetbestand.Inscriptsgebruikenwevqaakdehtml: html:-foptie,zoGdathtml: html:UnixnietnogeensvraagtofwehetwelU zekerweten.ۺhtml: html: Een_lekqanmeerderenamenofhtml: html:linkshebbGen;methetcommandohtml: html:lnwordteennieuwelinknaareenbGestaand bGestand1gelegd.html: html:ln/bin/ls/bin/dirmaakteennieuwcommando,html: html:dirgeheten,dathetzelfdedoetalshtml: html:ls.Methtml: html:rm wordthetaantallinksmetnverminderd.PaswanneerdattotnulisgedaaldenhetbGestandnietingebruikis, zalU html: html:UnixhetbGestanddaadwerkelijkU verwijderen.html: html: X Het*isnietmogelijknaareenlinktemakennaareendirectoryofeenbGestandopeenandereschijf.DezebGeperking wordtcopgehevendoGordehtml: html:symbGoliclinkofsnelkoppGeling,diejemaaktmethtml: html:ln-s.EensnelkoppGelingloopthetgevqaar datfhetbGestandwaarhijnaarverwijstnietbGestaatofdateencirculaireketenvqanlinksontstaat.V*ergelijkde uitvoGerU vqanhtml: html:ls-lLeensmethtml: html:ls-l.@html: html:html: html: 3 -rwxr-xr-xG1danielusers769Mai29example -rwxr-xr-xG1danielusers769Mai29voorbeeld lrwxrwxrwxG2danielusers%3Jun6example->wie lrwxrwxrwxG2danielusers%3Jun6voorbeeld->wiehtml: html:# 1.5.dRpro\#cessenenhunin-enuitvoerShtml: html: W*eVkzagenaldateenprogrammainhtml: html:UnixwordtopgeslagenineenbGestand.Eenhtml: html:Unixhtml: html:procesiseenlopendprogramma, metMAzijndataendecontextwaarinhetdraaitzoalsdehuidigedirectory*.MoGdernebesturingssystemenkunneneen proGcesEverdeleninzgn.html: html:threads;enprogrammakqandaarmeemeerderetakentegelijkuitvoGeren,diehundatadelen, watU alsnelineenchaoskqanontaarden.html: html: Dedshellzal,metuitzonderingvqaningebGouwdeopdrachten,dcommando'suitvoerendooreraparteprocessenvoor teFtstarten.ShellscriptswordendoGorgaansinafzonderlijkeproGcessen(subshells)uitgevoGerd.Ondanksdathtml: html:Unix' html: html:multi-taskingecinterxwerktdanhuis-,tuin-enkeukenbGesturingssystemen,maakthetvoGortdurendemakenen opruimenU vqanproGcessenshellscriptseenstuklangzamerdanandereprogrammeertalen.html: html: X Als^eenexternprogrammaisopgestartzaldeshellgewoGonwachtentotdathijeenseintjeontvqangtvandekernel datU hetkindproGcesisgestorvenc.q.beindigd.html: html: X DoGorZTeen`ampersand'achterZTeencommandotezettenalsinhtml: html:voorbeeld&,zalhet`indeachtergrond'ZTwordenverwerkt, enU deshellonmiddellijkomdevolgendeopGdrachtvragen.html: html: X EenvoGorbeeldvqaneeningebouwdeopdrachtishetcommandohtml: html:cd.Beginnersverbazenzichersomsoverdateenhtml: html:cd opGdrachtDbinneneenshellscriptwelwordtuitgevoGerd,maarheteektervqanvergetenisalshetscriptbGeindigdis enU terugkeertnaardeinteractieveshell.html: html: X Commando'sineenscriptkunnenoGokwordenuitgevoGerdmetbijv.html: html:../voGorbeeld.HiermeewordendeopGdrachten inthetbGestandvoorbeeldbinnendelopendeshelluitgevoerdenwerkthtml: html:cdbijvoGorbeeldtwel.Eenmindergebruikte mogelijkheid2isomprogramma's(nietalleenscripts)testartenmetdeopGdracht2html: html:execervoor.Erwordtdangeen apartpproGcesgemaakt,maarhetnieuwepprogrammawordtinhetlopendeprocesgeladenenvervqangthet,zodat hetU oGorspronkelijkeprogrammanaaoGopnietverderkqangaan.html: html: X T*ot decontextvqaneenproGcesbehorenookdestandaardinvoer-, uitvoer- enerror-kqanalen.V*ooreeninteractieve shellverwijstdestandaardinvoGernaarhettoetsenbordendeuitvoerenerrorkqanalennaarhetbeeldscherm.Alsu bGent(ingelogdviaeenmodemofnetwerk,(danverwijzendezekqanalennaaruwschermentoGetsenbord(inplaatsvqan datU vqandecomputerwaaropdeshelldraait.html: html:0ۺcolor push BlackF4Ff color popz֠Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍hjMety!html: html:./voGorbeeldresultaatwordendekqanalenomgeleidzodatdeinhoudvqanhetbestandhtml: html:datazalworden gelezenU endeuitvoGerinhetbestandhtml: html:resultaatkomt.U Eventuelefoutmeldingenkomennogophetscherm.ۺhtml: html: X Denotatiehtml: html:./voGorbeeldo>resultaat2>&1&zegtdathetscriptindeachtergrondmoGetdraaien.W*ezien toGch}geenresultaten.Hetdubbele`groterdan'tekengeeftaandatdeuitvoGerachterdebGestaandeinhoudvqan html: html:resultaatU moGetkomeninplaatsvqanhetbestandeersttewissen.html: html: X De-Caanduidinghtml: html:2>&1geeftaandathetstandaarderror-kqanaal(detweede-Chtml: html:le-descriptor)eenkopieisvannummer 1M(standaarduitvoGer),dusfoutmeldingenenresultatenverschijnendoGorelkqaarheeninhetbestandhtml: html:resultaat;het standaard-invoGerkqanaalkheeftle-descriptornummer0.Kindprocessenervenle-descriptors(openbestanden);de standaardMkqanalenzijnaltijdopGen.AlsdestandaardkanalenzijnomgeleidnaarbGestandenzijntoetsenborden bGeeldschermU tochU tebGenaderendooromteleidennaarhetpseudo-bestandhtml: html:/dev/tty.whtml: html: Een)html: html:here-doGcumentiseenbijzondergevqalvanomleidingwaarindeteverwerkengegevensinhetscript-bGestandzelf staan.@html: html:html: html: 3 fox=dog;Gdog=fox catG< html:cat).HetwoGord dat2alsmarkeringdientmoGetletterlijkwordenherhaaldopeenaparteregel.Deshellzalweleventuelesubstituties uitvoGerenU opdedata.html: html:! 1.6.dReenlesover`ls':jokertekensShtml: html: HetU volgendecommandoiseeneenvoudigevervqangingvoGorhtml: html:ls.@html: html:html: html: 3 echoG*|tr n"""\n"|columnhtml: html: HetWillustreerthoGedeshellhtml: html:jokertekensWofwildcardsbehandelt.AlserineenwoordeenjokertekenWvoorkomt,Wdan zal deshelldatwoGordvervqangendoGorallebestandsnamenindehuidigedirectorydieovereenkomenmetdat zoGekpatroon.html: html: X DeGhtml: html:*staatvoGoriederereeksvqannulofmeertekens,dushtml: html:lsa*zgeeftdelijstvqanallebGestandenwaarvqandenaam bGegintmeteenaeneindigtopz,zoals`alcatraz'(onderDOS/Windowskuntude*alleenaanheteindgebruiken). AlsU ergeencorrespGonderendebestandenzijndanblijftdeasteriskstaan,bijv.html: html:echoWie*dit*leest*is*gekhtml: html: X Het^$ismogelijktevoGorkomen^$datjokertekens^$wordenvervqangendoGorzetussenaanhalingstekenstezettenofdoGor erU eenbackslash(html: html:\)voGortezetten;html: html:ls\*@komtvqanpas,wanteenbGestandmetdenaamhtml: html:*isnietuitgesloten.html: html: ( Eenhtml: html:.corrrespGondeertmeteenwillekeurigteken,zoGdatdeshellhtml: html:p?nkqanvervqangendoGorhtml: html:panGpenpinpon.Eenreeks vqanxtekenstussenrechtehakenkqanwordenvervqangendoGornvandietekens,bijv.html: html:lsg-[123456789].jpgdoGorhtml: html:ls fig-1.jpgGfig-2.jpgwhtml: html: LetƢeropdathtml: html:ls*oGokdeinhoudvqansubdirectory'sweergeeft.html: html:lsgeeftalleenlesindehuidigedirectoryenhtml: html:ls*/ geeftU deinhoudvqanallesubGdirectory's.html: html:! 1.7.dRpijpleidingenShtml: html:0ۺcolor push BlackF5Ff color popОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍hjT*weeproGcessenkunnengemakkelijkviaeenhtml: html:pijpgekoppGeldworden,zoGdatdatadieuitdestandaarduitvoGervqan hetU eersteproGceskomen,doordestandaardinvoerU vqanhettweedeU proceswordenverwerkt,bijv.:html: html:ps-ef|sortHeteerstecommandogeefteenlijstvqanalleproGcessendiemomenteeldraaienenhetsortcommandosorteertze(opde@inlognaamvqandegebruiker;werkthelaasnietopallehtml: html:Unixversiesgelijk).AlsineenpijpeencommandowordtgebruiktdateenlenaamalsargumentnoGdigheeft,dankqanmeestal`-'wordengebruiktomdestandaardinvoGeraan7teduiden;veelcommando'sgebruikenautomatischdestandaardinvoGeralszegeenbestandsnaammeekrijgen.ۺhtml: html: X EenFprogrammadatdatavqanhetstandaardinvoGerkanaalFleestennaeeneenvoudigeFbGewerkingnaarhetstandaard uitvoGerkqanaalschrijftnoGemenweeenhtml: html:lter.Heteenvoudigstelterishtml: html:cat,datdataonveranderdkopieert;html: html:sortis ingewikkelder.html: html: X Eenϧanderlterishtml: html:dd;.V*oGordetailsziecolor push gray 0html:Paragraaf3.18 html: color pop;hiervolgteenvoGorbeeldϧhoejeeenbestandkuntconverteren naarU hoGofdletters:html: html:ddconv=ucasegesorteerd2>/dev/nullhtml: html: ( Ddwordtonderhtml: html:Unixwelgebruiktomeenoppydisktekopirenmethtml: html:ddif=/dev/fd0of=image-leV*ervolgens verwisselU jededisksenkopiertdeimageleterugnaaroppy*.html: html: X V*ergelijkLhetresultaatvqanhtml: html:nd/bin|sorteensmethtml: html:ls-1/bin/*enuzietdathtml: html:lsdegewoGonteLheeftdeuitvoer tesorteren.BijgebruikvqaneenpijpwordtdeuitvoGervqanheteersteprocesopgeslagenineenkleinehoeveelheid buergeheugen.U Alsdatvolis,wordtdeproGducentstilgezettotdatdeconsumentdezedataheeftverwerkt.html: html: X OmdeuitvoGervqaneencommandoophetschermtebGekijkenentegelijkeenkopieineenbGestandtebewaren gebruiktU menietsalshtml: html:./voGorbeeldU 2>&1|teeresultaathtml: html: ( AlsubGeschiktoverhettoGoltjehtml: html:html: html:netcat K(http://199.103.168.8:4984/web1/hak/netcat.html)dankuntuoGokop eenvoudige,&wijzegegevensovereennetwerkversturen.Inplaatsvqanhtml: html:prog1|prog2startuopmachinehtml: html:J aeitt10hosthtml: html:netcat -vFG-l-p1234|html: html:J aett10prog2enopdeanderemachinedoGetuhtml: html:html: html:prog1|netcathost1234Hierinishtml: html:1234degebruiktehtml: html:IP pGoort:eenminofmeerwillekeurignummer,mitsdebGetreendepoortnogongebruiktis,enhtml: html:prog1enhtml: html:prog2zijn willekeurigeU commando's.NetcatfungeerthierinalseenpijptussenproGcessenopverschillendecomputers.html: html: X AlleDhtml: html:UnixversieskennendebGovengenoemdeDhtml: html:anoniemepijp;sommigekennenoGokeenpijpdiealseenspecialele in hetbGestandssysteemvoorkomt. Eenpijpkqanwordenaangemaaktmethtml: html:mkfopijpofhtml: html:mknodpijppHethtml: html:mknod commandohwordtoGokgebruiktomspecialelesvqanhethtml: html:blockofhtml: html:charactertypGeaantemaken.ProbGeermaareens welkeU outputhethtml: html:lecommandoopeenspGecialelegeeft.html: html:%w2.E/elementairshellporogrammeren Whtml: html: 4܍ In"ditartikelwordtdeshellgeprogrammeerdmetbGehulpvqanscriptles.MoGderneshellsbezittenbovendien"de mogelijkheidU omkortemacro'stedenirenmetdehtml: html:aliasopGdrachtbijv.html: html:aliasl='ls-alg'html: html: X Aliassenkunneningewikkeldecommando'svervqangendoGoreenvoudigerteonthoudennamen.Zewordenvqaak gedenieerdOTinhtml: html:~/.profile,eenshellscriptdatelkekeeralsiemandinlogtwordtuitgevoGerd.Methtml: html:unaliaswordtde denitieU weerverwijderd.html: html: 2.1.dRvariab\#elenhtml: html: Dewerkingvqandeshellisvrijingewikkeld.Erzijnverschillendemanierenwaaropdeshellreeksentekenszalvervqan- gendoGorandere.Eendaarvqanisdeexpansievanaliassen:hetkommandohtml: html:l~/*/a*X6kanwordenuitgeschreventotbi- jvoGorbeeld8html: html:G/bin/ls-alg/home/gast/agf/aardappel/home/gast/agf/aardbei/home/gast/agf/appel/home/gast/autos/audihtml: html: Dealiaskwamenwezo0juisttegen;aan'ls'ishierhetpadtoGegevoegd.DetildestaatvoGordehtml: html:homedirectory#,waarop de5gebruiker`gast'inlogt;deuitdrukking`a*'wordtdoGordeshellvervqangendoGoreenlijstvanlenamendiemet eenU abGeginnen.html: html:0ۺcolor push BlackF6Ff color popОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍hjEenU html: html:vqariabGeleiseennaam,diedoordeshellaaneenreekstekenswordtgekoppGeldmetbijv.html: html:L='ls-alg'HetkommandosetzonderargumentengeefteenlijstvqanalleopdatmomentgedenieerdevqariabGelenmethunwaar- den.ہDeshellheeftzelfeenaantalingebGouwdevqariabGelenenanderevariabGelenwordenbijhetinloggengedenieerd,zoalsU html: html:$HOME,dehomedirectoryvqandegebruikerenhtml: html:$PWD,dehuidigedirectory*.ۺhtml: html: X W*e?zijnoGokaldevqariabelehtml: html:$P*ATHtegengekomen,?ookwelhetzoekpadgenoemd.Dewaardevqanhtml: html:$P*ATHis?een lijstJvqandirectory's,gescheidendoGordubbelepunten.Alseencommandodatgeenslash(/)indenaamheeft,niet is-ingebGouwdindeshellofalsaliasisgedenieerd,wordtgezoGchtofhetcommandoovereenkomtmetdenaamvqan eenU leineenvqandezedirectory's.html: html: X HetzelfdeCwkuntudoGenmethethtml: html:whichcommando,datechternietopallehtml: html:UnixsystemenbGestaat,ofwaarvoGorsoms eenU alternatiefhtml: html:whencevoGorbestaat.V*oorbeeld:html: html:whichndhtml: html: DeRshellzaleendollartekengevolgddoGordenaamvqaneenvariabGelevervangendoGordewaardevandebGetreende vqariabGele.U NukunnenwehetzelfdeeektalsvoGorheenkrijgenmethtml: html:$L.html: html: X HaddenDweechterLDdewaarde`l'gegeven,danzouhetresultaatgeweestzijn:html: html:l:Gcommandnotfound+BashDenksh brengenXonsinditgevqalverdermethtml: html:eval$LXHiermeewordtdeuitdrukking`l'nogeensgevalueerd,nadatdeshell de:waardevqanL:Pheeftgesubstitueerd.EenopGdrachtregelalshtml: html:$apGenkool:zalnietsdoGenenookgeenfoutmelding opleverenU alsdebGetreendevqariabelenietgedenieerdis.html: html: X W*eykrijgendewaardevqandevariabGelehtml: html:Lyterugmethtml: html:echo$L.Hetdollartekenmaakteigenlijkgeendeeluitvqande naam.xeAlswenueenscriptofanderprogrammaaanroGepenxewaarindewaardevqanvariabGeleLx\gebruiktwordt,zal dieechterongedenieerdzijn,tenzijweeerstdeopGdrachthtml: html:expGortLgevenomeenlokqalevariabGeleteexporteren naarU deprogramma-omgeving.EchoenexpGortzijningebouwdefunctiesvqandeshell.html: html:! 2.2.dRaanhalingShtml: html: IndevorigeparagraafwerddewaardedieaanLwerdtoGegewezenomgevendoGorenkeleaanhalingstekens.Deze zijngynoGdigomvqandeuitdrukkingnwoordtemaken,inclusiefdespaties.Dubbeleaanhalingstekenshaddenook voldaan.Hetverschilis,datbinnendubbGeleaanhalingstekensdevqariabGelennogsteedswordenvervqangendoGorhun waarde,U enalleenteksttussenenkeleaanhalingstekensletterlijkwordtovergenomen.html: html: X T*ussenDNdubbGeleaanhalingstekensbestaatnogdemogelijkheidomaantegevendateenenkeltekenexactmoGet wordenU gekopierd;ditgebGeurtdoorereenbackslashvoGortezettenalshtml: html:escapesymbool.html: html: X DeU programmeertaalCdenieerteenaantalescapGesymbGolen,dieookindeshellkunnenwordengebruikt.@html: html:html: html:html: html: \aU (alert)html: html:( color push BlackU color pop html: html:U (laateenpieptoGonhoren) html: html:html: html: ( \bU (backspace)html: html: color push BlackU color pop html: html:U verplaatstdecursoreenstapterug.(`x\bx'kqanwordengebruiktomeenxvetaftedrukken.) html: html:html: html: ( \fU (formfeed)html: html: color push BlackU color pop html: html:U geefteennieuweU pagina html: html:html: html: X \nU (newline)html: html: color push BlackU color pop html: html:U geefteennieuweU regel html: html:html: html: X \rU (carriagereturn)html: html: color push BlackU color pop html: html:U verplaatstdecursorterugnaarhetbGeginvqanderegel0ۺcolor push BlackF7Ff color popwОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: \tU (tabulator)html: html:( color push BlackU color pop html: html:U verplaatstdecursornaardevolgendetab-stop \tU (verticaltab)html: html: color push BlackU color pop html: html:U verplaatstdecursoreenstapomlaag V*erder1kunnenhtml: html:ASCIGItekenswordenaangeduidinoGctalenotatie,bijvoGorbeeld1\007(oGok\a)voGorhet teken.html: html: Hierbij\zijaangetekenddatdeechoopGdrachtvqandeshellvanzichzelfeen(regeleinde)toGevoegt,\tenzijer html: html:echoB-nisgebruikt;gebruikersvqanbashmoGetenechodehtml: html:-evlagmeegevenomdeescapGestelatenwerken.Het resultaatU kqanverschillenU alseroktalecoGdesbovenU 0200wordengebruikt.html: html: X EenSspGecialefunctievqandeshellisdehtml: html:commandosubstitutie,aangegevendoorachterwaartseSaanhalingstekens, bijv.g:html: html:L=`l`Hierwordteenapartesubshellgestart,waarinhetcommandohtml: html:ls-algwordtuitgevoGerd;hetresultaatis weerU tezienmethtml: html:echo"$L"0html: html: qЍ ProbGeernumaareenswatergebGeurtalsdedubbeleaanhalingstekenswordenweggelaten.Eenalternatievenotatie isomdetesubstituerenopGdrachttussenhtml: html:$(enhtml: html:)tezetten.Daarmeekunnengesubstitueerdeprocessenbovendien genesteldKworden.Letophetverschiltussendenotatieshtml: html:$(lijst;vqan;commando's)enhtml: html:(lijst;van;commando's):bGeide voGeren.deopgegevenopGdrachtenuitineenapartesubshell,maarwaardeuitvoGervqandetweedevqariantgewoGon tussenU destandaarduitvoGerverschijnt,wordtdeuitvoGerinheteerstegevqaleendeelvandeopGdrachtregel.html: html: X OmsBeenvqariabGeleaftescheidenvanderestvandetekstkandezewordenomgevendoGordubbeleaanhalingtekens ofdoGoraccolades,zodatdevolgendeuitdrukkingenalledewaardevqandevariabGelehtml: html:Levaluerenenerdeletters `OVE'U achterplakken.@html: html:html: html: echoG"$L"OVE 3 echoG${L}OVE echoG"${L}OVE" De]bGeperkingenvqandeshellalsprogrammeertaalwordenduidelijkalsjebijdevariabGelehtml: html:i1wiltoptellen.Rekenen ismogelijkmetbGehulpvqanhethulpprogrammahtml: html:expr,bijv.html: html:i=$(expr$i+1)LeteropdatdeshellspatiesnoGdig heeftU omdewoGordenteonderscheiden.html: html:# 2.3.dRparametersShtml: html: W*eNhebbGeninmiddelsenkelemanierengezienwaaropdeshellingevoGerdetekensbGewerkt,zoalsdesubstitutievqan vqariabGelenڙenverwijderenvanaanhalingstekens.V*ervolgenswordteencommandoinwoGordenopgeknipt,waarbij witruimte-descheidingtussendewoGordenaangeeft.Devqariabelehtml: html:IFSbevqatdetekensdiehierbijalsscheidingsteken wordengebruikt,standaardzijndit,en.Leteropdateenuitdrukkingtussenenkeleof dubbGelehaanhalingstekensaltijdalseenwoGordwordtgezien,oGokalbevqatzespaties.T*weeaanhalingstekensdirekt achterU elkqaartellenalseenwoGordmetlengtenul(0).html: html: ( Ineenshellscriptzijndeparameters(c.q.argumentenenvlaggen)bGeschikbaarviadespGecialevqariabelenhtml: html:$0t/mhtml: html:$9 (en-zonoGdigookhtml: html:${10}enhoger).html: html:$0isdenaamvqanhetprogrammazelf.Daarmeeishetmogelijkombijvoorbeeld html: html:gunzip&eenlinknaarhtml: html:gziptelatenzijnenhetprogrammaverschillend&telatenwerken&afhankelijkvqandenaam waarmeeU hetisaangeroGepen.html: html: X DeVshellkentVnogeenaantalspGecialeparameters;wezijnhtml: html:$?altegengekomen,dattelkensdeexitstatusvqanhet laatste`uitgevoGerdecommandokrijgt.html: html:$$bevqathethtml: html:Unixprocesnummervqandeshelldieuwscriptdraait.Ditkqan oGokU handigzijnomuniekelenamentemakenvoGortijdelijkebGestanden.html: html: X Deparametershtml: html:$*enhtml: html:$@leverendecompleteparameterlijstop,metuitzonderingvqanhtml: html:$0.T*ussendubbGeleaanhalings tekensgezetzalhtml: html:"$*"eenwoGordopleverendatovereenkomtmethtml: html:"$1G$2$3...",terwijlhtml: html:"$@"eenreekswoGorden html: html:"$1"G"$2""$3"...U geeft.DevqariabGelehtml: html:$#geefthetaantalargumenten.0ۺcolor push BlackF8Ff color pop GОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html: HieronderUvolgteenscriptjeommethetgebruikvqanparametersdoGordeshellteexperimenteren.Dehtml: html:shiftopdracht goGoit-jdeeersteparameterwegenschuiftderesteenpGositieop,metuitzonderingvqanhtml: html:$0.Deregelmethtml: html:whilewordt naderU toGegelichtincolor push gray 0html:Paragraaf2.6 html: color pop.@html: html:html: html: #!/bin/sh 3 echoG"Script$0aangeroepenmet$#parameters:" whileG[$#-gt0] donechoG-n"\"$1\""nshift done echo exithtml: html: Hetvverwerkenvqandeparameterlijstenkannogwatingewikkelderworden.Zokqanmetdenotatiehtml: html:${parameter:- woGord}Weenstandaardwaarde(default)wordenaangegevenvoGoreenweggelatenparameterofmethtml: html:{$parame- ter:?woGord}U eenfoutmeldingwordengegevenalsdeparameterverplichtis,bijvoGorbeeld@html: html:html: html: 3[ cpG${1:?"Deeersteparameterisverplicht"}\ 3%${2:-"."} ZoalswgezegdwordteenopGdrachtbGeindigddooreenpuntkommawofregeleinde.Hieriseenbackslashgebruiktom aanU tegevendatdeopGdrachtnognietafgelopGenis.html: html:! 2.4.dRals-danhtml: html: Demeestelementaireprogramma-constructielaatnofmeeropGdrachtenalofnietuitvoGeren,afhankelijkvqande uitkomstU vqaneentest,bijvoGorbeeld:@html: html:html: html:html: html: ifG/usr/bin/test"A"="a"8html: html: then 3nechoG"Gelijk"whtml: html: elsenechoG"Verschillend"html: html: fihtml: html: EerstwordtdeopGdrachtachterhtml: html:ifuitgevoGerd.ErwordtdangekekenwelkeexitstatusdieopGdrachtoplevert.De meeste\programma'sgevenstandaard0terug,en1ofeenanderefoutcoGdealserproblemenzijn,html: html:/bin/trueofhtml: html::is altijdU 0,enhtml: html:/bin/falsealtijd1.html: html:echo1zalweliswaar1alsoutputgeven,maarhetresultaatis0.html: html: ( DeopGdracht(en)achterhtml: html:thenwordenenkeluitgevoGerdalsdeif-opdracht0oplevert,anderswordthetdeelachter html: html:else,uitgevoGerd,maarhetopnemenvqaneenelse-takisnietverplicht.Deif-constructiewordtpasuitgevoGerdals het|sleutelwoGordhtml: html:isgelezen.Ineeninteractieveshellkrijgjeeenhtml: html:promptstringtezienomaantegevendatde shellopdevolgendeopGdrachtwacht.DezepromptwordtbGepaalddoordevqariabelehtml: html:PS1.Alseenopdrachtniet afgeslotenis,krijgtudepromptstringhtml: html:PS2tezien.DevoGorwaardelijkeopdrachtregelswordenhieringesprongen omU deleesbaarheidteverbGeteren.html: html: DeBourneshelliseenvrijbGeperktprogramma.V*oGoreenvoudigeberekeningenkqanhethulpprogrammahtml: html:exprworden gebruikt&enhtml: html:testvoGortestenenvergelijken.MoGderneshellsalsksh,bashoftcshhebbendezefaciliteitenvqaak0ۺcolor push BlackF9Ff color pop Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjingebGouwd.,Inplaatsvqandenotatiehtml: html:testhtml: html:expressiegebruikenzehtml: html:[html: html:expressie].Deshellwilspatieszientussende verschillendeonderdelenvqaneenexpressie,terwijlindeopGdrachtvariabGele=waardejuistgeenspatiesvoorofnahetU =-tekenmogenkomen.V*oGoruitgebreidereinformatieziecolor push gray 0html:Paragraaf3.1 html: color popencolor push gray 0html:Paragraaf3.2 html: color pop.ۺhtml: html: X BovenstaanddvoGorbeeldzalaangevendatdestringshtml: html:"A"enhtml: html:"a"verschillendzijn.HetzelfdegeldtvoGorhtml: html:test"1"= "01" terwijlhtml: html:test"1"-eq"01"moGetopleverendatbeideuitdrukkingenhetzelfdegetalvoorstellen.Deopdracht html: html:test -e"$le"komtophetzelfdeneeralshtml: html:ls"$le">/dev/null2>&1.ZetvqariabGelentussendubbeleaanhalingstekens, andersU zalhetfoutgaanalsdevqariabGelenietbestaatofleegis.html: html: X ErbGestaannogtweebeknoptevoorwaardelijkeopdrachten:html: html:html: html:commando1&&html: html:commando2enhtml: html:html: html:commando1||html: html:commando2 .-InbGeidegevqallenwordteersthtml: html:html: html:commando1uitgevoGerd.Inheteerstegevqalwordthtml: html:html: html:commando2alleenuitgevoGerdals hetE=eersteexitstatushtml: html:0(nul)oplevert,inhettweedegevqalalshetresultaatvanhtml: html:html: html:commando1ongelijkisaannul.Het resultaatU isdushtml: html:truealshtml: html:html: html:commando1html: html:enc.q.html: html:of0html: html:html: html:commando2html: html:trueopleveren.html: html:! 2.5.dRmeerkeuzetestshtml: html: Om dewaardevqaneenuitdrukkingindestandaarduitvoGertekrijgenwordtdehtml: html:echoopGdrachtgebruikt.Omeen waardeVvqandestandaardinvoGertelezenentoetekennenaaneenofmeervqariabelenwordthtml: html:readhtml: html:naam1=pnaam2... gebruikt.LDevqariabGelenkrijgendanelkeenwoordvqandeinvoerLalswaarde.Alsergeenvqariabelenwordenopgegeven, wordtU ereenregelgelezeneninz'ngeheeltoGegekendaanhtml: html:REPL*Y.html: html: X DeU ifconstructiekqanmetmeerderetestswordenuitgebreid:@html: html:html: html:html: html: ifGhtml: html:J aeitt10test1html: html: 3 thennhtml: html:commando1html: html: elsenhtml: html:ifGhtml: html:test2nhtml: html:then#chtml: html:commando2nhtml: html:elsen...nhtml: html:fihtml: html: fi DitU kqanoGokkorterwordengenoteerd.@html: html:html: html:html: html: ifGhtml: html:test1html: html: thennhtml: html:commando1html: html: elifGhtml: html:test2html: html: thennhtml: html:commando2html: html: elsen...html: html: fihtml: html: Om)deinhoudvqaneenvariabGelemetmeerderewaardentevergelijkengebruikenwedehtml: html:caseconstructie,zoalsin hetU volgendevoGorbeeld.@html: html:html: html: echoG-n$vraag n#variabelemoetgedefinieerdzijn 3 readGantwoord0ۺcolor push BlackG10Ff color pop Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjantwoord=$(exprGsubstr"$antwoord"11|tr\ 3)p"[a-z]"G"[A-Z]")ۺ8html: html: caseG$antwoordhtml: html:in [YJDOS]G)nexitG0;; NG)nexitG1;; *G)nechoG"Ongeldigantwoord!"1>&2nexitG2;;=html: html: uD esac HierBwordteenvraaggesteldeneenantwoGordvqandegebruikeringelezen,waarvqandeeersteletterwordtgenomen enkleinelettersinhoGofdlettersvertaald.Decaseconstructievergelijkthtml: html:antwoGordmeteenaantalpatronenenvoGert deU reeksbijbGehorendeopdrachtenU uit,diewordtafgeslotenmeteendubbelepuntkomma.html: html:html: html: X Y((yes),(html: html:J(ja),html: html:D(da),html: html:O(oui)ofhtml: html:S(si)retournerenexitstatushtml: html:0(true),html: html:N(neinofnjet)retournerenhtml: html:1(false)enalle andereLwinvoGerkomtovereenmetdeasteriskenresulteertin2metbijbGehorendefoutmeldingophetstandarderror kqanaal.html: html: EenFvqarianthieropisdehtml: html:selectconstructie,dienietindeorigineleBourneshellvoGorkomt,waarmeeeenvoudige menu'sU kunnenwordengemaakt.@html: html:html: html: echoG-n$vraagwhtml: html: selectGwoordhtml: html:injaneehtml: html: do 3nhtml: html:ifG/usr/bin/test"$woord"!=""nhtml: html:thenbreaknhtml: html:fi done HiercwordtdekeuzevqandegebruikerbGeperktctothtml: html:1(ja)ofhtml: html:2(nee).Letopdathtml: html:"$woGord"hiertussenaanhalingstekens moGet staanomdatdevergelijkingandersnietgoedgaatalsdewaardevqandevariabGeleeenlegestringis(gebruiker heeftU ongeldigeinvoGerU gepleegd).html: html:! 2.6.dRherhalingenShtml: html: In{]hetvoGorbeeld{]hierboven{]wordtdeinvoGerzolangherhaald,totdatdegebruikereengeldigewaardeheeftingevoGerd. EenU meeralgemeneherhalingwordtgeschrevenals@html: html:html: html:html: html: whileGhtml: html:testhtml: html: 3 donhtml: html:opdracht1n...nhtml: html:opdrachtn{html: html: done HierinwordttelkensdeopGdrachtachterhtml: html:whileherhaaldenzolangalshetresultaathtml: html:0oftrueoplevertwordtdereeks opGdrachtenqtussendoendoneherhaald,watdusooknulkeerhetgevqalkanzijnendetest(inderdaadisdatvaak het[testcommando)wordtaltijdeenkeermeeruitgevoGerddandeopdrachten.[Eenvoorbeeldvqanhetgebruikvan whileU zagenweincolor push gray 0html:Paragraaf2.3 html: color pop.html: html: X Dehtml: html:untilconstructielijkthiersterkop.HierinwordtdelijstvqanopGdrachtenherhaaldzolangalshetresultaat ongelijkU isaanhtml: html:0.DeuitvoGeringvqanhetscriptgaatdanverdermetdeopGdrachtna`done'.@html: html:0ۺcolor push BlackG11Ff color pop Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: untilGhtml: html:testhtml: html: 3 donhtml: html:opdracht1n...nhtml: html:opdrachtn{html: html: donehtml: html: DeU html: html:forconstructiewordtoGokvqaakgebruikt.@html: html:html: html:html: html: forGhtml: html:variabeleEhtml: html:inhtml: html:lijsthtml: html: do 3nhtml: html:opdracht1n...nhtml: html:opdrachtn{html: html: done Achterhtml: html:forstaatdenaamvqaneenvariabGelezonderdollarteken.BijelkedoGorgangkrijgtdevqariabeledewaardevqan hetU volgendewoGordindelijst.W*egevenenkelevoGorbeelden.@html: html:html: html:html: html: forGfilehtml: html:in*html: html: donhtml: html:ifG[-f"$file"]nhtml: html:thenwcG"$file"nhtml: html:fi donehtml: html: HierwordtvoGorelkeleindehuidigedirectoryhetcommandohtml: html:wcuitgevoGerd,dathetaantalregels,woGordenen tekensinhetbGestandtelt.Gebruikvqanhtml: html:wc*isnietzonetjesomdatdanoGokdirectory'senspecialelesworden meegenomen.@html: html:html: html:html: html: forGihtml: html:in12345678910html: html: 3 donhtml: html:forGjhtml: html:in12345678910nhtml: html:doechoG-n$(expr$i'*'$j)""nhtml: html:donenechohtml: html: donehtml: html: HerhalingsopGdrachten8kunnenprimagenestwordenzoalsinbovenstaand8voorbeeld,8datdetafelsvqanvermenigvuldig- ing+afdrukt.Letopdeenkeleaanhalingstekensrondhetsterretje.Erstaathtml: html:-nachterechoomdetafelsopnregel teU houdenenerwordteenspatietussenruimteingevoGegd.html: html: X AlshetwoGordhtml: html:inendevolgendelijstafwezigzijndankrijgtdevqariabGeleachtereenvolgensdeparameterstoGegewezen waarmeeU hetscriptwerdaangeroGepen,U zodatwehetprogrammavqancolor push gray 0html:Paragraaf2.3 html: color popkunnenherschrijvenals@html: html:html: html: echoG"Programma$0isaangeroepenmet$#parameters"whtml: html: forGihtml: html: 3 donechoG$i8html: html:0ۺcolor push BlackG12Ff color pop /֠Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjdoneۺhtml: html: Een"XwhileluskqanoneindigdoGorlopen"XalsvoGordetesthtml: html::ofhtml: html:/bin/truewordtingevuld.EenluskqanvoGortijdigworden verlatenImetdehtml: html:breakopGdracht;methtml: html:break2wordtingevqalvantweeIgenestelussendebuitensteverlaten,enzovoGorts. DeopGdrachthtml: html:continuezorgtervoGordatdelijstopdrachtennietverderwordtafgewerktenhetscriptverdergaat metU detest.html: html:# 2.7.dRsamenstellingenShtml: html: T*ot]desamengesteldecommando'sbGehorenif,case,select,while,for,untilendefuncties,dieverderopaanbGod komen.U HetsimpGelstesamengesteldecommandois@html: html:html: html: { 3nhtml: html:opdracht1n...nhtml: html:opdrachtn }html: html: Hetvhtml: html:groGepcommandozaldecommando'sindegroepnaelkqaaruitvoeren.Deexitstatusvqandelaatsteopdracht istevenshetresultaatvqandegroGep.ZokanbijvoGorbeeldeenpijplijnalseenopGdrachtwordenbGehandeldmethtml: html:{ html: html:opdracht1U |html: html:opdracht2;}.html: html: ( AlsA~eenlijstcommando'sinplaatsvqanaccoladestussenrondehakenhtml: html:()wordtgezet,wordendiebinneneenaparte html: html:subshelluitgevoGerd.Ditgeldtookvoorhtml: html:$(html: html:lijst).InhetlaatstegevqalwordtdeuitvoGervqandelijstalsdeelvan hetU scriptgebruikt.html: html:! 2.8.dRfunctieshtml: html: Deadenitievqaneenhtml: html:functiebGestaatuitdiensnaammeteenpaarhakenerachter,doGorgaansgevolgddoGoreenlijst commando's.@html: html:html: html:html: html:html: html: 3 functie-naam() {nhtml: html:opdracht1n...nhtml: html:opdrachtn }html: html: EenWfunctieaanroGepbestaatuitdenaamvqandefunctiegevolgddoordeeventueleWhtml: html:argumentengescheidendoGor spaties.UDebGetreendecommando'swordendannvoGornindehuidigeshelluitgevoGerd,waarnahetscript verderU gaatwaarhetgeblevenwas.BinnendefunctiezijndeargumentenbGeschikbaaralshtml: html:$1G...html: html: X De uitvoGeringvqandefunctiestoptbijdeafsluitendeaccoladeofnaeenreturnopdracht, diebijvoorkeur delaatste opGdracht%4binnendefunctievormt.%4Achterreturnkqaneventueeleenexitstatusvolgen,dieaanhetaanroGepende scriptbGeschikbaarkomtinhtml: html:$?.Deexitstatusisaltijdeengeheelgetal.Alseenstringalsresultaatgewenstis,kqandat resultaathbijvoGorbeeldmetechowordenuitgevoGerdendefunctieviacommandosubstitutiewordenaangeroGepen. InU plaatsvqanhtml: html:foriin12345678910@kanhtml: html:foriin`range110`wordengeschrevenmetdevolgendefunctie:@html: html:html: html:html: html: range()0ۺcolor push BlackG13Ff color pop?2Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hj{Gtypesetii 3)pi=$1)pwhileG["$i"-le"$2"])pdoechoG$ii=`exprG"$i"+1`)pdone)punsetGi}ۺhtml: html: HetkqanhandigzijnomfunctiedenitiesineenapartbGestandhtml: html:functiestezettenendiemethtml: html:./functiesofhtml: html:source functiesCintelezen.BashzaleennaameerstprobGerentekoppelenaaneenalias,daneenfunctieenalslaatsteeen bGestandU metdezelfdenaamgaanzoekeninzijnpad.html: html: X Binnen}defunctiezijndezelfdevqariabGelenalsinderestvanhetscripttegebruikenengewijzigdewaardenblijven oGok9naaoopbestaan.IndeKornenBashshellkunnenookhtml: html:lokqalevariabGelenwordengedeclareerdmetdehtml: html:typGeset opGdracht,իdiealleenbinnendefunctiecontekstbestaat.InBashkqanhetzelfdeookmethtml: html:localwordenbereikt.Een lokqaleU variabGelemaskeerteeneventueleglobalevqariabGelemetdezelfdenaam.html: html:! 2.9.dRenkelevo\#orbeeldenhtml: html: Het$volgendevoGorbeeldprogramma$geeftdenamenvqandeingelogdegebruikers.Naeentweetalfunctiedenities volgtU hethoGofdprogramma,datbestaatuiteenpijpvqanvijfsegmenten.@html: html:html: html:html: html: word() 3 {Gif["$#"-gt1]ntheni=0;Gn=$1;shiftforGjin$@do(KifG[$i=$n](Kthen18echoG"$j"18break(Kelse18i=$(exprG$i+1)(Kfidonenfi }html: html: item() {GOFS=$IFS;IFS=":"nNR=$1;GshiftnwordG$NR"$@"nIFS=$OFS }html: html: #Khethoofdprogramma whoG\ |GwhilereadLINE1ndo0ۺcolor push BlackG14Ff color popQОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjwhileGreadLINE2 3doifG["$(word0"$LINE1")"="$(itemG0"$LINE2")"]then uechoG-e"$(item0"$LINE2")\011$(item4"$LINE2")"fidoneG html: Defunctiehtml: html:wordretourneerthet1html: html:7Lecrm0600eaargument,datwordtgebruiktomeenregelinwoGordentesplitsen;handigerdan daarhtml: html:awkvoGortegebruiken.Defunctiehtml: html:itemmaakthandiggebruikvqandeingebGouwdeshellvqariabGelehtml: html:IFSomde dubbGeleL^puntinplaatsvqandespatiealsscheidingstekentegebruiken.HethoGofdprogrammadoetnietsandersdan uitdeuitvoGervqanhtml: html:whodeusernameteknippenendietevergelijkenmethetcorresponderendevelduithtml: html:/etc/passwd. DeU uitvoGerwordtdangesorteerdendubbGeleregelsverwijderd.html: html: X DezeafunctieswordenoGokweergebruiktinhetvolgendescriptvoGorsystemendienietovereenhtml: html:whichcommando bGeschikken (ziecolor push gray 0html:Paragraaf2.1 html: color pop).DitscripthoudtechtergeenrekeningmetaliasseneningebGouwdefunctiesvqande shell.@html: html:html: html:html: html: 3 which_p() {Gf=0nwhileG:ndof=`exprG$f+1`dir=`itemG"$f""$PATH"`ifG["$dir"=""]then(Kbreakfipath=$dir/$1ifG[-f"$path"]then(KechoG"$path"(Kbreak%fi done }html: html: #Khethoofdprogramma`which' ifG[`exprmatch"$1"'.*/.*`-gt0] thennifG[-f"$1"]nthenechoG"$1"nfi elsenechoG`which_p"$1"` fihtml: html:0ۺcolor push BlackG15Ff color pop[ Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjHetqvolgendeprogrammatoGontverschillentussentweebGestanden,maarhetiseenstukbeperkterdanhethtml: html:di commando.BNHierwordtzoalsuitgelegdincolor push gray 0html:Paragraaf1.5 html: color pophetstandaardinvoGerkqanaalomgeleidnaarhetbestanddatalsVeersteargumentopdecommandoregelismeegegevenenerhettweedebGestandwordtgekoppGeldaanhetderdeinvoGerkqanaal.@html: html:ۺhtml: html:html: html: 3 doit() {GLINE=0nwhileGreadEEN<&0ndoLINE=`exprG$LINE+1`readGTWEE<&3ifG["$EEN"!="$TWEE"]then(KechoG"$LINE""c""$LINE"(KechoG"<$EEN"(KechoG"---"(KechoG">$TWEE"findone }html: html: #Khoofdprogramma ifG["$#"-ne2]nthennechoG"Usage:$0file1file2"nexitG1 fi ifG[-r"$1"-a-r"$2"] thenndoitG0<$13<$2nexitG0 elsenechoG"Invoerbestand(en)onleesbaar"nexitG1 fihtml: html:# 2.10.dReenvo\#orbeelddRvaneenrecursievefunctiehtml: html: EenIfunctiemagoGokzichzelfaanroepen(recursie),waarbijjemoetvoorkomenIdatdatprocesoneindigdoorgaat.In onderstaand+SvoGorbeeldvoorbashenkshvindtderecursiealleenplaatsalshtml: html:$1>0enwordthetargumentverlaagd omU tezorgendatnaeenaantalstappGenhtml: html:$1gelijkwordtaan0.@html: html:html: html:html: html: Hanoi() 3 {GtypesetiaantalnifG["$1"-gt"0"]nthenaantal=$(exprG$1-1)HanoiG"$aantal""$2""$4""$3"echoG"Verplaatseenschijfvan$2naar$3"HanoiG"$aantal""$4""$3""$2"nfi }8html: html:0ۺcolor push BlackG16Ff color popeSОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍"ֈ#U#KAanroepenmet: 3HanoiG4"A""B""C"ۺhtml: html: V*oGortwiehetspelhtml: html:deT*orensvqanHanoinognietkent:tjehebteentorenvan4(of64,maardanduurthetspGelerg lang)¹goudenschijven¹vqanverschillende¹diameter,diejenvoGornvanstapGelA”naarBmoGetverplaatsen,waarbij noGoitoeengrotereschijfbovenopoeenkleineremagkomenteliggen.Deoptimaleoplossingisomdebovensteodrie schijvenLeerstrecursiefvqanA8naarCteverplaatsen,waarnadeondersteschijfvqanA8naarBkqanwordenverplaatst enU derestweerrecursiefvqanCnaarB.html: html: OmtebGewijzendateenrecursiefalgorithmekorrektis,isinductienodig.Hetistriviaalinteziendathetalgorithme eend~stapGelvqannulschijvenvqanAdAnaarBverplaatstdoGornietstedoen.V*oorn>0verplaatsjeeerstdebovenliggende (n-1)schijvenvqanAnaarCennahetverschuivenvqandenhtml: html:eF,weervanCnaarB.Alswemogenaannemendathet verplaatsenvqan(n-1)schijvenkorrektwordtuitgevoGerd,dangaatwerkthetopdezemanieroGokvoGoreentoren vqanU nschijven.html: html: X Deinductieregelstelt,dataangezienhetalgorithmehetgewensteeektheeftvoGorn=0endatvoGorelken !", cmsy100 geldt, datalshetgoGedgaatvoorn,ookeentorenvqan(n+1)schijven korrektwordtverwerkt.Opdezelfdemanier is>tebGewijzendatalselkeschijfgroterisdandeschijferbGoven,hetalgorithmenoGoiteengrotereschijfbGovenopeen kleinere@zalleggen:detorenvqan(n-1)schijven@isaltijdkleinerdandeondersteendeondersteschijfkomtnoGoit ergensU bGovenopteliggen.html: html: X UitU hetalgorithmevolgteenrecurrentebGetrekkingvoGorhetaantalverplaatsingen:@html: html:html: html:html: html: 荍U V(0)U =0荍U V(n)U =2V(n-1)+1ۺhtml: html: DoGorseentabeltemakenvqandewaardenvoGorverschillendenziejealsneldatditovereenkomtmetV(n)=2html: html:n -1, watU vervolgensgeverierdkqanworden.@html: html:html: html:html: html: 荍U V(0)U =20-1=0荍U V(n)U =2(2n-1-1)+1=2n-1ۺhtml: html: BewijzendatergeensnellerewegbGestaat,ismoeilijker.Hetkritiekepadishetverplaatsenvqandeondersteschijf vqan `A 1naarB.V*oGordathetzover `is,moetendeschijven `erboven `eerstopnofanderemaniernaarC 1worden verplaatst%endaarnaweernaarB.EenvqandeweinigealternatievenisomeerstvqanA naarCteverplaatsen,en daarnaHvqanC html:! 2.11.dRsignalenShtml: html: W*e*4hebbGenalgezienhoeweprocessenindeachtergrond*4kunnenstartenenkennisgemaaktmeteenmanieromde manieromtweeproGcessentecordinerendoormiddelvqaneenpijp:heteersteprocesmagzolangindepijpschrijven totdat:6dekleinebuervolis;danzalhtml: html:UnixhetstoppGentotdaterweervoldoGenderuimtevrijis.HetlezendeproGces wordtU telkensalsdepijpleegisindewachtgezet.html: html: X De meestevormenvqaninterproGcescommunicatievergeneenhogereprogrammeertaal.V*oGordeshellprogrammeur zijn$designalenhetbGelangrijkst.html: html:Unixheefttwintig$totdertigvoorgedenieerdehtml: html:signalenplustwee$vrijdenieerbare. MetdeopGdrachthtml: html:killhtml: html:signaal=pprocesstuurjeeensignaalnaarhetopgegevenproces.Denummersvqandeprocessen zijnvmethtml: html:psteachterhalen.vHetnummervqanhetproGceszelfistevindenindevariabGelehtml: html:$$eninbashzithet0ۺcolor push BlackG17Ff color popoGОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjouderproGcesrinhtml: html:$PPID.DenummersvqandesignalenverschillenenigszinspGerhtml: html:Unixversie;designalenkunnenoGok metRsymbGolischenamenwordenaangeduid;voGorbashbeginnendiemetdelettershtml: html:SIG,maarindekornshellmoetditU voGorvoegselU wordenweggelaten.ۺhtml: html: X HeteektvqaneensignaalisindemeestegevallendathetopgegevenprogrammaonmiddellijkwordtbGeeindigd. V*oGorhtml: html:SIGKILL޺(9)isditaltijdhetgevqal.Hetligtvoordehanddatalleenhtml: html:roothetrechtheeftomandermansprocessen teh|doGden.Hetbesturingssysteemkqanzelfbesluiteneenproceseensignaaltegeven.Alseenprogrammastoptmet html: html:segmentationGviolation,html: html:buserror,html: html:floatingpointexceptionofhtml: html:illegalinstructionduidtdatmeestalopeen programmeerfout;U shellscriptsveroGorzakenU dezefoutenzelden.html: html: X DegebruikerheefteensnelleremanieromsignalennaarhetproGcesopdevoGorgrondtesturen.Dezekunnenvrij wordenxveranderdmethetcommandohtml: html:stty#.Methtml: html:stty-akrijgjeeenlijstvqandeingesteldewaarden,bijvoGorbeeld html: html:html: html:Ctrl-html: html:D voGor%html: html:SIGHUP,html: html:html: html:Ctrl-html: html:Cofhtml: html:DelvoGorhtml: html:SIGINT,html: html:html: html:Ctrl-html: html:\html: html:SIGQUIT.Methtml: html:html: html:Ctrl-html: html:ZwordteenlopGendprogrammatijdelijk onderbroken.DOnderbashkqaneenscriptzichzelfonderbrekenmetdehtml: html:suspGendopdracht.DDeingebouwdeopdrachten metU html: html:fgenhtml: html:bgzetteneenonderbrokenjobvoGortindevoGor-resp.achtergrond.html: html: Xcolor push Black,. ecrm0900* color pop(xme:$uitleggenw html: $ MettdeopGdrachtthtml: html:sleephtml: html:secondenwordteenprogrammatijdelijkonderbrokenenzalhetnahetopgegevenaantal secondenwmethtml: html:SIGALRMKwordengewekt.Dehtml: html:waitopGdrachtonderbreekteenproGceszolangtotdathetvqanhtml: html:Unixhet signaal֪html: html:SIGCHLD֊krijgtdathetopgegevenkindproGcesofjobindeachtergrondbGeindigdis.html: html:W*aitzonderargumenten wacht+totdatallekinderenafgestorvenzijn.AlseenproGcesindevoGorgrondgestartis,wachtdeouderzonder explicietU waitcommando.html: html: X Een\proGceskqanervoorkiezenbepaaldesignalengewoontenegeren,metuitzonderingvqanhtml: html:SIGKILL\enhtml: html:SIGSTOP.Het html: html:SIGHUPsignaaldataangeeftdateenterminalgebruikerde(telefoGon)verbindingheeftopgehangenwordtgenegeerd met?Mhtml: html:nohupcommando&.DestandaarduitvoGerenerrorkqanalenwordendanomgeleidnaarhetbGestandhtml: html:nohup.out.whtml: html: Signalen^wordenasynchroGonverwerkt,onafhankelijkvqanwaareenproGcesmeebezigwasennaaoopgaathet programmaU verderwaarhetgeblevenwas,tenzijhetbGeindigdis.html: html: X MetFhetcommandohtml: html:traphtml: html:commando=psigna(a)l(en)wordtaangegevendateenbGepaaldcommandomoetworden uitgevoGerdDealshetvolgendesignaalc.q.nvqandesignalenwordtontvqangen.Ditzalvaakdenaamvandefunctie zijn4diehetbGetreendesignaalmoetafhandelen.Alseenscriptvoortijdigmoetwordenafgebrokenzalzo'nfunctie bijvoGorbeeldU tijdelijkebGestandenverwijderen.html: html:html: html: X T*rap,3heeftgeeneektopkindproGcessen.Alshetcommandohtml: html:-luidtofontbreekt,danwordtdeoGorspronkelijke handelwijze2hersteld.Alshetcommandoeenlegestringis,danzaldelijstvqansignalendoGorhetscriptworden genegeerd.html: html:%w3.E/enkoeleUnixtonols33html: html: De&html: html:UnixshellisvqanoudsherdeenigeprogrammeertaalzonderingebGouwdeoptelling.Optelleneneeneindeloze reeksbanderefunctieskunnenechterbgerealiseerdwordendoGorexterneprogramma's.DeverzamelingvqantoGolsdie standaardImethtml: html:UnixwordengeleverdvormeneenkrachtigenexibGelgeheel.Dithoofdstukbehandeltereenpaar dieU voGoralgeschiktzijnvoGorgebruikinscripts;hetpretendeertnietvolledigtezijn.html: html: X EenEmoGdaleUnixcommandoregelbegintmetdenaamvqanhetprogramma,gevolgddoGordeopties,diemeteenmin- tekencbGeginnen,metdaarnadeoverigeparameters,dievqaakbGestandenzijn.V*eelalmogenerookmeerderebestanden voGorkomen.Deoptiesmogeninwillekeurigevolgordewordengebruiktenoptiesvqannlettergecombineerdvqan html: html:prog5-a-bhtml: html:filetotbijv.html: html:prog-abhtml: html:file.V*erderkunnenargumentenaanoptieswordengekoppGeldmetietsalshtml: html:prog -ahtml: html:-variabele=waarde-b...aofhtml: html:prog-ahtml: html:-variabele=pwaarde-b...;letopwanneerjewelofgeenspatiesmoGet gebruiken.html: html:0ۺcolor push BlackG18Ff color popОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hj3.1.dRexprۺShtml: html: Wie{eenrekenmachine{zoGektgebruiktmeestalhtml: html:bcofhtml: html:xcalc.html: html:Exprisspeciaalvoorshellscripts.Elkargumentiseen getalofeenopGerator,enmoetdoorspatiesgescheidenworden;spGecialetekensmoGetendoorbackslashesworden voGorafgegaan.ExprkentgeenvqariabGelen;daarvoGorzijnshellvqariabelen.Omeengetalmetdrietevermenigvuldigen gebruikenU weietsalshtml: html:i=`expr"3"\*"$i"`html: html: ( DerekenkundigeopGeratorenhtml: html:+voGoroptellen,html: html:-voGoraftrekken,html: html:*voGorvermenigvuldigen,html: html:/voGordelenenhtml: html:%voGor restÀwerkenmetgehelegetallen.DevergelijkingsopGeratorenhtml: html:>,html: html:<,html: html:>=,html: html:<=,html: html:=(inhtml: html:GNU[exprookhtml: html:==)enhtml: html:!=kunnen oGokvoorstringswordengebruikt.Integenstellingtotdeshellretournerenzeeenhtml: html:1alsdevergelijkingwaarisen andershtml: html:0,evenalsdeopGeratorenhtml: html:|(logische`of')enhtml: html:&(logische`en').Inplaatsvqaneennulmagdelegestring worden,pgebruiktenexpressieskunnentussenhaakjeshtml: html:()gezetworden.Letopdatinhtml: html:if$(expr"$i"="")Xde aanhalingstekensU omdevqariabGelenaamnietgemistkunnenworden.html: html: X De7|KornshellenbashhebbGenookeeningebouwderekenfunctie:detebGerekenenuitdrukkingwordtomgevendoGor html: html:$((enhtml: html:)).Hierwordengeenaanhalingstekensgebruiktendespatieszijnnietvereist.ErzijnextraopGeratoren:html: html:= staatvoGortoewijzing,dusvoorvergelijkingwordthtml: html:==gebruikt.Behalveindedecimalenotatiekunnengetallen oGok>octaalwordengenoteerddoorzemethtml: html:0tebeginnenofhexadecimaaldoorerhtml: html:0xvoortezetten.Hetgebruikvqan deU ingebGouwdefunctiebespaarthtml: html:Unixdetijdvoorhetmakenvqanhet`expr'proces.html: html: X Expr kentoGokeenpatroonherkenningoperatorhtml: html::dieeenstringvergelijktmeteenreguliereexpressie(ziecolor push gray 0html:Paragraaf 3.3 html: color pop).U DezeopGeratorleverthetaantaltekensdatovereenkomtop.html: html: ( MoGdernereU versiesvqanhtml: html:exprbezitteneenaantalstringfuncties.@html: html:html: html:html: html: matchU html: html:string=pregexp8Phtml: html:ǰ color push BlackU color pop html: html:U eenalternatievenotatievoGorpatroonherkenning html: html:html: html: substrU html: html:string=pbeginlengtehtml: html:ǰ color push BlackU color pop html: html:U retourneerteendeelvqandestringvanlengtetekensvanafpGositiehtml: html:begin;positieswordenvqanafhtml: html:1geteld 8Phtml: html:html: html: ǰ indexU html: html:string=ptekenshtml: html: color push BlackU color pop html: html:U retourneertdeeerstepGositieindehtml: html:stringwaarnvqandereekstekensvoGorkomt 8Phtml: html:html: html: ǰ lengthU html: html:stringhtml: html: color push BlackU color pop html: html:U retourneerthetaantaltekensindestringhtml: html:# 3.2.dRtesthtml: html: Hetthtml: html:testcommando,datwordtgebruiktinvoGorwaardelijkeopGdrachten,zijnwealtegengekomen.Letopdattest eentingebGouwdefunctievqanmoderneshellsalsbashofkshis,dieerglijktophtml: html:/usr/bin/test.Dieingebouwdetest functieM kqanoGokwordengenoteerdalshtml: html:[html: html:expressie].Deeerstetoepassingisomtetestenofeenbestandbestaat.html: html:html: html:html: html: ( -dU html: html:filehtml: html: color push BlackU color pop html: html:U waaralsdeleeendirectoryis html: html:html: html: X -fU html: html:filehtml: html: color push BlackU color pop html: html:U waaralsdeleeennormaalbGestandis html: html:html: html: -rU html: html:filehtml: html: color push BlackU color pop html: html:U waaralsjehetrechthebtomdeletelezen0ۺcolor push BlackG19Ff color popОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: -wU html: html:filehtml: html: color push BlackU color pop html: html:U waaralsjehetrechthebtomnaardeleteschrijven html: html:html: html: X -sU html: html:filehtml: html: color push BlackU color pop html: html:U waaralshetbGestandnietleegishtml: html:html: html: X -tU html: html:kanaalhtml: html: color push BlackU color pop html: html:$waaralshetkqanaalhtml: html:(ledescriptor)aaneenterminalgekoppGeldis.html: html:UnixkoppGeltelkbestanddatgeopend wordt^aaneennummer.Omtelezenofteschrijvenverwijsjenaardatnummer.eenbGestandkqanevt.dubbel geopGend html:commandohtml: html: html: HedendaagseU UniceshebbGenwatmeeropties.DetweedegroGeptestsvergelijktstrings.@html: html:html: html:html: html:html: html: string1U =html: html:string28Phtml: html:ǰ color push BlackU color pop html: html:U waaralsbGeidestringsgelijkzijn html: html:html: html:html: html: string1U !=html: html:string2html: html:ǰ color push BlackU color pop html: html:U waaralsbGeidestringsverschillen html: html:html: html:html: html: string1html: html:ǰ color push BlackU color pop html: html:U waaralsdestringnietdelegestring""is html: html:html: html: -nU html: html:string1html: html:ǰ color push BlackU color pop html: html:U waaralsdelengtevqandestringgennulbGedraagthtml: html: OminplaatsvqanstringsgehelegetallentevergelijkenwordendeopGeratieshtml: html:-eq,html: html:-ne,html: html:-gt,html: html:-ge,html: html:-lt,html: html:-legebruikt. Getallenqwordenalsstringsweergegeven.Hetverschilisdathtml: html:test"02"-eq"2"html: html:0(true)zalopleverenenhtml: html:/usr/bin/test "02"="2"html: html:1(false).Ditresultaatkrijgtutezienmethtml: html:echo$?.html: html:/usr/bin/expr"02"="2"zalopdestandaard uitvoGerU html: html:1(true)schrijvenendeexitstatushtml: html:0(true)retourneren.html: html: ( DevierdegroGepzijndeverbindingen.html: html:!html: html:expressiestaatvoGorlogischenegatie,html: html:html: html:expressie1-ahtml: html:expressie2vormteen logischeyhtml: html:enenhtml: html:html: html:expressie1-ohtml: html:expressie2eenlogischehtml: html:of.V*erderkunnensubGexpressiestussenhtml: html:()haakjesworden gezet.html: html:! 3.3.dRgrepenreguliereexpressiesShtml: html:html: html: GrepiseentoGolomintekstbestandentezoeken;metbinairebestandenkunnenveelvqandehierbesprokentools problemengeven.Ukunthethtml: html:stringscommandogebruikenomleesbaretekstfragmententevissenuitallesoGorten les.html: html: Sindshetontstaanvqanhtml: html:UnixzijnerveelversiesmetverschillendekenmerkeninomloGopenbovendienzijnerhtml: html:egrep, html: html:fgrepU enhtml: html:agrepbijgekomen.T*enbGehoeveU vqandepGortabiliteitzijnegrepoffgrepaantebevelen.html: html: X HierondervolgtdesyntaxisvqandefgrepopGdracht.Derechtehakengevenaandateenonderdeeloptioneelisen wordenU ineenechteopGdrachtregelnietopgeschreven,evenminalscursievetermenletterlijkwordengenomen.@html: html:html: html: fgrep@html: html:U [html: html:=poptie...]html: html:html: html:string...html: html:[html: html:file...]0ۺcolor push BlackG20Ff color popОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjF*grepishetbGeperktsteentevenssnelstelidvqandefamilie.Alsereenenkelestringalsargumentwordtmeegegeven functioneertU hetalseenlterdatvqanderegelsindeinvoGerU degenedoorlaatdiedeopgegevenstringbevqatten.ۺhtml: html: X Er kqanopmeerderestringswordengezoGcht,diedanwordengescheidendoGoreenregeleinde.Destringsmoetendan tussen2aanhalingstekenswordengezetomeenargumenttevormenenalleregelsdienvqandestringsbGevatten wordenU afgedrukt.F*grepkentdevolgendeopties.@html: html:html: html:html: html: -vhtml: html: color push BlackU color pop html: html:U alleregelsafdrukken,bGehalvedegenediedegezoGchtestringsbGevqatten html: html:html: html: -chtml: html: color push BlackU color pop html: html:U alleenhetaantalregelsafdrukken html: html:html: html: -lhtml: html: color push BlackU color pop html: html:U denamenvqandelesafdrukken,diedegezoGchtestringsbGevqatten html: html:html: html: -ihtml: html: color push BlackU color pop html: html:U geenonderscheidmakentussenhoGofd-enkleineletters html: html:html: html: -whtml: html: color push BlackU color pop html: html:U regelswaarindezoGekstringeendeelvqaneenwoGordvormttellennietmee html: html:html: html: -xhtml: html: color push BlackU color pop html: html:U alleenregelsdiehelemaalgelijkzijnaandezoGekstringtellenmeehtml: html: ErrbGestaanmeeropties,maardieverschillenrpersysteem.Alsjewilttestenofeenbepaaldestringineenbepaaldele voGorkomtkunjedehtml: html:-s(silent)optiegebruiken(BSD),ofhtml: html:-q(quiet,GNU)omdestandaarduitvoGerteonderdrukken.html: html: ( HetPvolgendevoGorbeeldPgeefteenlijstvqanaljeproGcessen.(dejuisteoptiesvanpshangenafofjeOS html:html: html: 3[ psG-al|fgrep`fgrep$USER/etc/passwd|cut-f3-d':'`html: html: Debinnenstehtml: html:fgrepselekteertderegelvqandeingelogdegebruikeruithetwachtwoGordbestand.html: html:Cutkniptdaaruit het<_derdeveld,waarbijdedubbGelepuntalsscheidingstekenwordtgebruikt.Debuitenstefgrepselecteertderegels metU dithtml: html:UserIDuitdeuitvoGervqanhtml: html:ps.V*ergelijkmethetvoGorbeeldU uitcolor push gray 0html:Paragraaf2.9 html: color pop.html: html: X DefunctionaliteitvqangrepzelfverschiltnogalpGersysteem,endaaromwordthierhetuitgebreiderehtml: html:egrepbesproken. De=optieszijnhetzelfde,maarhetzoGektnaarhtml: html:reguliereexpressiesinplaatsvqanalleenletterlijkestrings.Reguliere expressieslijkenopdewildcards(jokertekens,ziecolor push gray 0html:Paragraaf1.6 html: color pop)*en?diedeshellgebruiktomnaarbGestandsnamen tezoGeken,maardenotatieverschiltsterk.DenkeraandezoGekstringtussenenkeleaanhalingstekenstezettenom verhaspGelendoordeshelltevoorkomen.HetkqangeenkwaadomzelfeenswatteprobGerenopeengrotewoGordenlijst.html: html:html: html:html: html: egrepG-i'abc 3 def'G/usr/share/dict/words HiermeezoGekenwenaarallewoGordenwaarindelettershtml: html:abcen/ofhtml: html:defdirektachterelkqaarstaan.DewoGordenlijst zouU oGokinbijv.html: html:/usr/dict/wordskunnenstaan.html: html:0ۺcolor push BlackG21Ff color popMОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍hjReguliereU expressiesmoGetenvoldoenaandevolgenderegels.ۺhtml: html:html: html:X color push Black€ color pophtml: html:U EenenkeltekendatgeenspGecialefunctieheeft,komtovereenmetdattekenzelfhtml: html:X color push Black€ color pophtml: html:U OmtezoGekennaareentekendateenspGecialefunctieheeft,moetjeereenhtml: html:\voorzetten,bijv.html: html:egrep'\\'html: html:( color push Black€ color pophtml: html:ȺEenreekstekenstussenvierkqantehakenwordtgebruiktomtezoGekennaareenenkeltekenuitdezereeks,zo correspGondeertU html: html:[0123456789]meteenenkelcijfer.html: html: color push Black€ color pophtml: html:uT*ussenvierkqantehakenkqaneenreekstekenswordenaangegevenmeteenkoppGeltekentussenheteersteenlaatste teken,U bijv.html: html:[0-9].html: html: color push Black€ color pophtml: html:U EenpuntcorrespGondeertmeteenwillekeurigteken,bijv.html: html:.a.b.c..demet`barbGecuede'.html: html: color push Black€ color pophtml: html:Dereguliereexpressiehtml: html:html: html:exp1html: html:html: html:exp2correspGondeertmethtml: html:string1html: html:string2alshtml: html:html: html:exp1correspondeertmethtml: html:string1 en $html: html:html: html:exp2correspGondeertmethtml: html:string2,waarbijhtml: html:string1delangstmogelijkestringiswaarvoGornogeencorre-spGondentieU methtml: html:html: html:exp2mogelijkis.8Phtml: html:ǰ color push Black€ color pophtml: html:U Dereguliereexpressiehtml: html:(html: html:exp)correspGondeertmetallestringsdiecorresponderenmethtml: html:html: html:exp.html: html:( color push Black€ color pophtml: html: Dereguliereexpressiehtml: html:html: html:exp1|html: html:exp2 correspGondeertmetallestringsdiecorresponderenmethtml: html:html: html:exp1html: html:ofhtml: html:html: html:exp2.IetshandigerU daneenregeleinde.html: html: color push Black€ color pophtml: html:QDereguliereexpressiehtml: html:html: html:exp1*correspGondeertmetallestringsdienulofmeerkeercorrespGonderenmethtml: html:html: html:exp1.ZokomtNhtml: html:a.*b.*c.*d.*eovereenNmeto.a.`AbGcoude'enblijktbijv.html: html:egrep`(bla)*(bla)'dezelfdeoutputopteleverenalsU html: html:fgrepbla.html: html: color push Black€ color pophtml: html:U Dereguliereexpressiehtml: html:html: html:exp1+isequivqalentmethtml: html:html: html:exp1(html: html:exp1)*.html: html:( color push Black€ color pophtml: html:U Dereguliereexpressiehtml: html:html: html:exp1?isequivqalentmethtml: html:html: html:exp1|().html: html: color push Black€ color pophtml: html:U Dereguliereexpressiehtml: html:html: html:exp1\{html: html:aantal1\}U isequivqalentmethtml: html:html: html:exp1html: html:html: html:aantal1keerachterelkqaar.html: html: color push Black€ color pophtml: html:U Dereguliereexpressiehtml: html:html: html:exp1\{html: html:aantal1,\}U isequivqalentmethtml: html:html: html:exp1html: html:html: html:aantal1ofmeerkeerachterelkqaar.html: html: color push Black€ color pophtml: html:DLDereguliereexpressiehtml: html:html: html:exp1\{html: html:aantal1,html: html:aantal2\}DLisequivqalentmethtml: html:html: html:exp1minstenshtml: html:html: html:aantal1enhoGogstenshtml: html:html: html:aantal2 keerU achterelkqaar.html: html: color push Black€ color pophtml: html:U Dereguliereexpressiehtml: html:^html: html:exp1correspGondeertmetalleregelswaarinhtml: html:html: html:exp1aanhetbGeginvqanderegelvoorkomt.8Phtml: html:ǰ color push Black€ color pophtml: html:U Dereguliereexpressiehtml: html:html: html:exp1$correspGondeertmetalleregelswaarinhtml: html:html: html:exp1aanheteindvqanderegelvoGorkomt.8Phtml: html: ǰ EenxuitbreidingopdeReguliereExpressies,dieoudereUnicesmissen,zijndehtml: html:kqarakterklassendieeenuitbreiding vormenU vqandelijstenkarakters.html: html:html: html:html: html: X [[:alpha:]]html: html: color push BlackU color pop html: html:U delettersvqanhetalfabGet html: html:html: html: [[:uppGer:]]html: html: color push BlackU color pop html: html:U dehoGofdletters html: html:html: html: [[:lower:]]html: html: color push BlackU color pop html: html:U dekleineletters html: html:html: html: [[:digit:]]html: html: color push BlackU color pop html: html:U decijfers html: html:html: html: X [[:xdigit:]]html: html: color push BlackU color pop html: html:U dehexadecimalecijfers0ۺcolor push BlackG22Ff color pop날Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: [[:punct:]]html: html:( color push BlackU color pop html: html:U deleestekens [[:graph:]]html: html: color push BlackU color pop html: html:U dezichtbareU tekens html: html:html: html: [[:print:]]html: html: color push BlackU color pop html: html:U deafdrukbaretekens(zichtbaretekensplusdespatie html: html:html: html: ( [[:blank:]]html: html: color push BlackU color pop html: html:U despatieenhettabulatie-teken html: html:html: html: X [[:space:]]html: html: color push BlackU color pop html: html:U allewitruimte(html: html:[[:blank:]]plushtml: html:verticaltabenhtml: html:formfeed html: html:html: html: ( [[:cntrl:]]html: html: color push BlackU color pop html: html:U destuurtekenshtml: html: W*elkeitekenstotdezeklassenbGehorenisafhankelijkvqanuwhtml: html:loGcale.Alshtml: html:UnixuwmoGedertaalis,dantyptuhtml: html:expGort LANG=C9ofOhtml: html:expGortLANG=POSIX.Deklassehtml: html:[:upper:]bevqatdanalleendehtml: html:ASCII9tekensA-Z,maarmethtml: html:expGort LANG=nl_NL*worden*SoGokdediakritischetekensalsĘۀɀҀрŀijcxj O׀methtml: html:ASCIGI*nummersbGoven127toGe gerekend.U Ookdevolgordevqandeoutputvanhtml: html:sort-d-fisafhankelijkmetdeingesteldeloGcale.html: html: X Dethtml: html:equivqalentieklassenzijneveneensafhankelijkvqandeloGcaleenwordendoGorhtml: html:GNUTnognietgoedondersteund. Dewnotatiehtml: html:[[=html: html:letter=]]duidtdeverzamelingvqantekensaandieinhetwoGordenboekwopdezelfdeplaatskomen, zoalsU hoGofdlettersenlettersmeteenaccent.html: html: Dehtml: html:GNUversieheeftweereenuitgebreideresetvqanregels,waaronderdemogelijkheidomterugterefererennaar een%eerdereRE% tussenhaakjesmeteenbackslashgevolgddoGorhetnummervqandieexpressie,bijv.html: html:([a-z])Giseen \1.*"correspGondeertmetregelsals`aiseenaap0je,dateetuitzijnpoot',`biseenbakker,diebaktvoGoronsbrood'.html: html: X NogAuitgebreiderdanegrepishtml: html:html: html:agrep,h(http://www.tgries.de/agrep/)eenalgorithmevqanSunW*uenUdiManbGer. HiermeeU kunjezoGekenopstringsdieongeveergelijkzijnaanhetzoGekpatroon.html: html: X DeZbGelangrijksteextraoptieishetmaximumtoegestaneaantalfouten(lettersdiejemoetwijzigen,toevoegen, vervqangen.omzemethetzoGekpatroon.telatenovereenkomen).Alseersteoptiewordtdanhtml: html:-1,G-2,....aangegeven.html: html: ( Een4andereextraoptieismogelijkheidtezoGekennaarallestringsdieeenuitbreidingvqanhetzoekpatroonbevqatten. InU plaatsvqanhtml: html:egrep'a.*b.*c.*d.*e'schrijfjedanhtml: html:agrep-p'abGcde'.html: html:! 3.4.dRndenxargsShtml: html: Een-tvqandemeestvoGorkomende-ttakenvqanshellscriptsishetzoGekennaarbGepaaldebestandenenhetbewerken ervqan.G ScriptprogrammeursgebruikenhiervoGorlieverhtml: html:nddanls.FindzoGekteendirectoryendienssubdirectory's recursiefVafenlevertalsuitvoGereenreekspadnamen(namenvqanbestandenplusdirectory's)dieaanbepaalde criteriaU voldoGen.DeuitvoGerwordtnietgesorteerd.html: html: X OmU eencommandouittevoGerenopelkvqandegevondenbGestandenzoujeietskunnendoenals@html: html:html: html: forGbestandin`find....` 3 donhtml: html:commandoE$bestand done0ۺcolor push BlackG23Ff color popОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍hjDit;heefthetnadeeldatdeoutputvqanndpGotentieelenormlangkanzijn,terwijlshellsmaareenbGeperkte lengtegvoGoreencommandoregelkunnenaccepteren.Dezemaximalelengtekunjevindenmethetcommandohtml: html:nd/usr/includeU -namelimits.h-follow-execgrepARG_MAX\{\}\;2>>/dev/nullۺhtml: html: ( Deoplossingisdehtml: html:xargsopGdracht,diehetcommandonaarwensherhaalt,bijvoGorbeeldtienkeermettelkenshonderd argumenten,U alserduizendbGestandenzijngevonden.DesyntaxisvqandezeopGdrachtenluidt:@html: html:html: html: X nd@html: html:U [html: html:=pfile...]html: html:[html: html:expressie]html: html:|\html: html: xargs@html: html:U [html: html:=poptie...]html: html:[html: html:commando]html: html:[html: html:argument...]html: html: HetGvolgendevoGorbeeldGzoektallecoredumpsinuwhomedirectoryensubdirectory's.html: html:nd~-name"core"-print |U xargslehtml: html: ( DelijstvqanargumentenbGegintmeteenreeksdirectory'sdiewordendoGorzocht,gevolgddoGoreenoptionelereeks vqanɁtestseneenofmeerhtml: html:akties.DeaktieswordenalleenuitgevoGerdalsalleoptieshtml: html:trueopleveren;ermagoGokhtml: html:-a tussenjPwordengezet.AlsmeerdereoptieswordenverbGondendoorhtml: html:-odanzaldecombinatiewaar(0)opleverenals n1fervqanwaaris.HetresultaatvaneenoptiekanwordenomgekeerddoGorereenhtml: html:!voGortezettenenoptiesmogen tussen@html: html:(G)haakjeswordengegroGepeerd.@DehaakjesmoGetendooreenbackslashwordenbGeschermdtegensubstitutie doGorU deshell.html: html: FindU kentdevolgendetests:@html: html:html: html:html: html: X -nameGhtml: html:"string"{html: html: color push BlackU color pop html: html:waaralsdenaamvqandeleovereenkomt;destringmagwildcardsbGevqattenmitserhaakjesomheenof backslashesU voGorstaan html: html:html: html: -permGhtml: html:getalhtml: html: color push BlackU color pop html: html:waaralsdehtml: html:pGermissiebitsovereenkomenmethetoktalegetal.html: html:manchmoGdgeeftmeerinformatieoverdeze numeriekeU moGdes. html: html:html: html: -typeGhtml: html:twhtml: html: color push BlackU color pop html: html:EwaaralshetbGestandvqanhettypGehtml: html:tw%is;html: html:fstaatvoGoreengewonele,html: html:dvoGoreendirectory*,html: html:bvoGoreenblock spGecialTleenhtml: html:cvoorcharacterspecialle.NieuwereTsystemenkennenookhtml: html:pvoornamedpipes,html: html:svoorsockets enU html: html:lvoGorhtml: html:symbGoliclinks(snelkoppGelingen). html: html:html: html: ( -linksGhtml: html:nhtml: html: color push BlackU color pop html: html:U waaralshetbGestandhtml: html:nlinksbezit.html: html:html: html: -userGhtml: html:naamhtml: html: color push BlackU color pop html: html:U waaralshetbGestandeigendomisvqangebruikerhtml: html:naam;datmageenloginnaamofnummerzijn. html: html:html: html: X -groupGhtml: html:naamwhtml: html: color push BlackU color pop html: html:U waaralshetbGestandeigendomisvqangroephtml: html:naam;datmageengroepnaamofnummerzijn.html: html:html: html: -sizeGhtml: html:nhtml: html: color push BlackU color pop html: html:waaralsdegroGottevqanhetbestandhtml: html:nAhtml: html:diskblocksbedraagt.Eendiskblockis512bytesgroGot,nietteverwarren metU deblokkenvqan1024bytesvqanhtml: html:df.html: html:html: html: -inumGhtml: html:nhtml: html: color push BlackU color pop html: html:U waaralshetbGestandhtml: html:inodenummerhtml: html:nheeft.0ۺcolor push BlackG24Ff color pop%Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: -atimeGhtml: html:nhtml: html: color push BlackU color pop html: html:U waaralshetbGestandgedurendedelaatstehtml: html:ndagenisgebruikt. -mtimeGnhtml: html: color push BlackU color pop html: html:U waaralshetbGestandgedurendedelaatstehtml: html:ndagenisgewijzigd. html: html:html: html: X -newerGhtml: html:file{html: html: color push BlackU color pop html: html:U waaralshetbGestandrecenterisgewijzigddandeopgegevenhtml: html:filehtml: html: IndevoGorafgaandeoptieskqangehalvehtml: html:nomeenaantalaanteduidenoGokdenotatie+html: html:nwordengebruiktvoGor aantallenU groterdanhtml: html:nof-html: html:nomaantallenkleinerdanhtml: html:naanteduiden.html: html: Het volgendevoGorbeeld zoektnaarandermanslesinuwhomedirectory*.html: html:nd~\!-user$USER-typGef-print| xargsU ls-lhtml: html: FindU kentdevolgendeakties:@html: html:html: html:html: html: -printwhtml: html: color push BlackU color pop html: html:druktdenaamvqanhethuidigebGestandafopdeuitvoGer.Indehtml: html:GNUversiekqandezeaktiewordenweggelaten. html: html:html: html: -execGhtml: html:commandohtml: html: color push BlackU color pop html: html:waaralsdeexitstatusvqanhethtml: html:commandohngelijkisaannul.HetcommandomoGetwordenbGeindigdmeteen puntkomma.U Alshetcommandohtml: html:{}bGevqat,danzaldatwordenvervqangendoGordehuidigelenaam. html: html:html: html: -okGhtml: html:commandohtml: html: color push BlackU color pop html: html: ĺwaaralsdeexitstatusvqanhethtml: html:commandoۤgelijkisaannul.FindvraagtdaneerstombGevestigingenvoGerthet commandoU alleenuitalserhtml: html:ywordtingevoGerd. DeU html: html:GNUversieheeftnogveelmeeropties,onderandere:@html: html:html: html:html: html: X -followhtml: html: color push BlackU color pop html: html:U volgsymbGolischelinks html: html:html: html: -mounthtml: html: color push BlackU color pop html: html:U slagemountelesystemenover html: html:html: html: -maxdepthGhtml: html:nivowhtml: html: color push BlackU color pop html: html:U daaldedirectorybGoomU slechtstothetopgegevenaantalhtml: html:nivo'saf.html: html: Hierondereenietsanderemanieromhtml: html:corelestezoGeken.Letopdebackslashes.html: html:nd~-namecore-execle\{\}\; -print|grepcoreEenhandigemanieromdeinhoudvqandirectoryhtml: html:origineel=metallesubGdirectory'stekopiren naar}directoryhtml: html:bestemmingT]gebruiktdehtml: html:pass-throughoptievqanhtml: html:cpio:html: html:ndhtml: html:origineel-print|cpio-pGdmhtml: html:bestemming. html: html:SCOU html: html:UnixheefthiervoGoreenhtml: html:copyxcommando.html: html:! 3.5.dRdirectory'sdo\#orlopendRmetduShtml: html:0ۺcolor push BlackG25Ff color pop?ϠОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjDewhtml: html:duutilitygeefteenoverzichtvqandehoGeveelheidschijfruimtedieeenbGepaaldedirectorysamenmetdeon- derliggende٪subGdirectory'sinbeslagneemt.Behalvealseenuitgebreideversievqanhtml: html:dfkunjehetoGokbeschouwenalsU eensnellevqariantopnd,diealleendirectory'sweergeeft.Desyntaxisluidt:@html: html:ۺhtml: html: X du@html: html:U [-a]html: html:[-k]html: html:[-s]html: html:[-x]html: html:[html: html:=pdirectory...]html: html: AlsU ergeendirectory'sopgegevenzijn,bGekijktdudehuidigedirectory*.Deoptieszijnalsvolgt:@html: html:html: html:html: html: -aU (all)html: html:( color push BlackU color pop html: html:U geefdegroGottevqanalleles,nietalleendirectory's html: html:html: html: -kU (kilobyte)html: html:( color push BlackU color pop html: html:U rappGorteerdeschijfruimteU inkilobytes;destandaardeenheidkqan512bytesof1024byteszijn. html: html:html: html: -sU (summary)html: html:( color push BlackU color pop html: html:U geefslechtsU nregelpGerdirectory html: html:html: html: -xU (exclude)html: html:( color push BlackU color pop html: html:U sladirectory'sopgemounteschijvenoverhtml: html:# 3.6.dRsed,editenvanuiteenscriptShtml: html: MetbGehulpvqanegrepkunjeinformatiezoekenineentekstbestand.Omregelstewijzigeniserdehtml: html:streameditor sed,2ZeenbroGertjevqandehtml: html:ededitor,dieweereenvoGorloper2Zvqanhtml: html:viis,diespGeciaalgemaaktisvoGorgebruikinscripts. SedkopierttelkenseenvolgenderegelvqandeinvoGernaardehtml: html:patroonbuer,voGertdeopdrachteninzijneditscript nU voGornuitenkopiertdebuernaardeuitvoGer.Desyntaxisluidt:@html: html:html: html: sed@html: html:U [-n]html: html:[-ehtml: html:script]html: html:[-fhtml: html:sfile]html: html:[html: html:=pfile...]html: html: Alsdelenaamof-namenontbrekendanzalseddestandaardinvoGerverwerken.Heteditscriptkqanopdecomman- doregelachterdehtml: html:-evlagtussenaanhalingstekenswordenmeegegevenofwordengelezenuitdelediemetdehtml: html:-f vlagQwordtaangeduid.Alsdehtml: html:-nvlagwordtgebruikt,danwordteralleenuitvoGergegeneerddoordeprintopdracht.html: html: Onderstaand_scriptjeprintderegelsuithetwachtwoGordbestand_diedelettershtml: html:rotofhtml: html:rootbGevqatten,netalsegrep. ZonderU dehtml: html:-nvlagzoudendezedubbGelwordengeprint.html: html:sed-n-e'/ro\+t/p'/etc/passwdhtml: html: ( SedU scriptszienernogcryptischeruitdanshellscripts;zebGestaaninhetalgemeenuitregelsvqandevorm@html: html:html: html: [U html: html:adres1html: html:[,html: html:adres2]]html: html:[!]html: html:[argument...]html: html: Een~QscriptregelzonderadreswordttoGegepastopelkeregelindeinvoGer,metnadreswordtdefunctietoGegepast op>#elkeregeldiemethtml: html:adres1overeenkomt,enmettweeadressenopderegelsvqanafdeeerstedieovereenkomtmet html: html:adres1totdevolgendedieovereenkomtmethtml: html:adres2.Alsdatnietgewordenwordt,totaanheteindvqandele. AlsU achterhetadreseenuitroGeptekenstaatwordtdefunctietoGegepastopalleregelsdienietgeselecteerdzijn.html: html:0ۺcolor push BlackG26Ff color popUoОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍hjEenadreskqaneendecimaalregelnummerzijn,catvanaf1geteldwordt,html: html:$voGordelaatsteregelofeenreguliere expressie=3tussenschuine=3strepGen.Dehtml: html:GNU=-versiestaattoedereguliereexpressietebegrenzenmeteenandertekendandeslash.HetvolgendevoGorbeeldretourneertderegelstussen'roGot'en`bin'uithterwachtwoGordbestand.html: html:sed-eU '\#roGot#,\#bin#!d'/etc/passwdۺhtml: html: ( SedU kentonderanderedevolgendefuncties:@html: html:html: html:html: html: X pU (print)html: html:( color push BlackU color pop html: html:pkopierdeinhoudvqandepatroGonbuernaardeuitvoGer;zonderdehtml: html:-noptiekqandatresulterenindubbel afgedrukteU regels. html: html:html: html: nU (next)html: html:( color push BlackU color pop html: html:druktdeinhoudvqandepatroGonbuerafopdeuitvoGerenleestdevolgenderegelvqandeinvoGerindepatroon- buer. html: html:html: html: dU (delete)html: html:( color push BlackU color pop html: html:U maakdepatroGonbuerleegengaverdermetdevolgenderegel. html: html:html: html: html: html: X aU \html: html:html: html: ( tekst@html: html: color push BlackU color pop html: html:U plaatseenregeltekstindeuitvoGervoGordatdevolgenderegelwordtgelezen.html: html:html: html: html: html: X cU \html: html:html: html: ( tekst@html: html: color push BlackU color pop html: html:U MaakdepatroGonbuerleeg,schrijfdetekstnaardeuitvoGerenleesdevolgenderegelin.html: html:html: html: html: html: X iU \html: html:html: html: ( tekst@html: html: color push BlackU color pop html: html:U plaatseenregeltekstindeuitvoGer.Appendeninserthebbenhooguitnadres.html: html:html: html: X qU (quit)html: html:( color push BlackU color pop html: html:U bGeindighetprogrammazonderderestvqandeinvoerU telezen.Quitgebruikthooguitnadres.html: html:html: html: X =U (regelnummer)html: html:( color push BlackU color pop html: html:U schrijfhetregelnummernaardeuitvoGeropeenaparteregel.html: html:html: html: X wGhtml: html:file{html: html: color push BlackU color pop html: html:U voGegdeinhoudvqandepatroonbuertoeaanhetopgegevenbestand.html: html:html: html: rGhtml: html:file{html: html: color push BlackU color pop html: html:qleesdeinhoudvqanhetopgegevenbGestandenschrijfdienaardeuitvoGeralvorensdevolgendeinvoGerregelte lezen.0ۺcolor push BlackG27Ff color popl.Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: hU (hold)html: html:( color push BlackU color pop html: html:U vervqangdeinhoudvandehtml: html:houdbuerdoGordievandepatroGonbuer. gU (get)html: html: color push BlackU color pop html: html:U vervqangdepatroGonbuerdoGordeinhoudvqandehoudbuer. html: html:html: html: X xU (exchange)html: html: color push BlackU color pop html: html:U verwisseldeinhoudvqandepatroGonbuerendehoudbuer. html: html:html: html: X y/html: html:string1/html: html:string2/U (yield)html: html: color push BlackU color pop html: html:U vervqangtekensuithtml: html:string1doGorovereenkomstigetekensvqanhtml: html:string2;bGeidestringsmoetenevenlangzijn. 8Phtml: html:html: html: ǰ NU (next)html: html: color push BlackU color pop html: html:KJvoGegdevolgenderegeltoGeaandepatroonbuermeteenregeleinde(html: html:\n)ertussen.Normaliterbevqatdebuer geenU html: html:\n. html: html:html: html: X DU (delete)html: html: color push BlackU color pop html: html:U V*erwijderdeeersteregelvqandepatroGonbuerengaverdermetdevolgendeinvoGerregel. html: html:html: html: X GU (get)html: html: color push BlackU color pop html: html:U plaatseenregeltextindeuitvoGervoGordatdevolgenderegelwordtgelezen. html: html:html: html: X PU (print)html: html: color push BlackU color pop html: html:U kopierdeeersteregelvqandepatroGonbuernaardestandaarduitvoGer. html: html:html: html: X HU (hold)html: html: color push BlackU color pop html: html:U voGegdeinhougvqandepatroonbuertoeaandehoudbuer. html: html:html: html: X #Ghtml: html:commentaarhtml: html: color push BlackU color pop html: html:U Naeenhekjewordtderestvqanderegelgenegeerd,netalseenlegeregelhtml: html:html: html: html: html: {U html: html:functie1html: html:html: html: ( functie2U ...8Phtml: html: ǰ }@html: html: color push BlackU color pop html: html:InplaatsvqaneenfunctiewordtdehelegroGepuitgevoGerd.F*unctiesopnregelmogenookdoorpuntkomma's wordenU afgesloten.html: html:html: html: s/html: html:regul.Kexpressie/html: html:vervanging/[html: html:flags]U (substitute)html: html:( color push BlackU color pop html: html: tzoGektekstenvervqangdie.AlsvoGorhetadresreedseenzoekexpressieisgebruikt,kqanachterdehtml: html:seenlege expressieostaan.Deagskunneneenhtml: html:gomvqattenalsermeerderesubstitutiesineenregelkunnenvoGorkomen,een html: html:pomdepatroGonbuerteprintenalsereenvervqangingisgemaaktenhtml: html:wGhtml: html:file)omdeinhoudvandepatroGonbuer naarU deleteschrijvenU alserietsisvervqangen. html: html:html: html: :html: html:naam㶺(labGel)html: html:( color push BlackU color pop html: html:U doGetniets,maarmarkeerteenpositieomnaartoetespringen.0ۺcolor push BlackG28Ff color pop~Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: bG[html: html:naam]U (branch)html: html:( color push BlackU color pop html: html:GgaverdermetdevolgendefunctieachterhetlabGelhtml: html:naam.Alsdenaamisweggelaten,springnaarheteindvqan hetU scriptengaverdermetdevolgendeinvoGerregel. html: html:html: html: X tG[html: html:naam]U (test)html: html: color push BlackU color pop html: html:ȮgaverdermetdevolgendefunctieachterhetlabGelhtml: html:naamalsersindshetinlezenvqandeinvoGerregelofsinds de$vorigetestopGdrachteensuccesvollesubstitutieheeftplaatsgevonden.Alsdenaamontbreektwordternaar hetU eindvqanhetscriptgesprongen.html: html: HetPvolgendevoGorbeeldPzetregelnummersvoGordeinvoGer;html: html:BSDPenhtml: html:gnusystemenbGereikenhetzelfdemethtml: html:cat-n. Omdatderegelnummersopaparteregelskomen,wordteentweedesedcommandogebruiktomzesamentevoGegen enU deregeleindentevervqangendoGorspaties.@html: html:html: html: sedG-n-e'=;p'|sed-n-e'N;s/\n//p'html: html: DeU volgendevqariantillustreerthoGemettweetaladressenmeerdereregelbGereikenwordengevonden.@html: html:html: html: lsG/bin|sed-n-e'/name/,/t/{=;p;}'|\ 3nsedG-n-e'N;s/\n//p'html: html: Het*volgendevoGorbeeld*zeteenspatieachteriedertekeneneenlegeregelachteriedereregelenvervqangtallekleine lettersU doGorhoofdletters.@html: html:html: html: 3 sedG-e's/\(.\)/\1/g y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/ G'html: html: V*oGormeerinformatieenvoorbeelden,ziehtml: html:theseders'grab-bag.(http://seders.icheme.org/)Hiernavolgteenwat uitgebreider-shellscriptdatgebruikmaaktvqansedomcommentaarinChtml: html:++[stijlteverandereninstandaardCcoGde. HetGmaaktgebruikvqanledigesubstitutiesomtetestenofeenbGepaaldpatroonindeinvoerregelGvoorkomt.GDe functieU html: html:extensionbGehoeftU wellichtverbGeteringvoGornamenalshtml: html:app-1.0.0.tar.gz.@html: html:whtml: html:html: html: subst() 3 {Gsed-e'6q//\*/s/$//6qtGloop6qbGcont :loop6q/\*//s/$//6qtGcont6qn6qbGloop :cont6q/\/\//s/$//6qtGfound6qb :found0ۺcolor push BlackG29Ff color popyОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hj,a/\".*\/\/.*\"/s/$// 3,at,a/\*\/\/\*/s/$//,at,a/\/\*.*\/\/.*\*\//s/$//,at,a/\/\//s/$/G\*\//,a/\/\/.*\/\*.*\*\//s/\*\///,a/\/\//s//\/\*/,at,a'G$1}ۺhtml: html: stringlen() {Gif["$1"=""]nthenechoG"0"nelseexprGlength"$1"nfi }html: html: substring() {Gif["$1"=""]nthenechoG""nelseexprGsubstr"$1""$2""$3"nfi }html: html: lastindex() {Gname="$1"nDotPos1=0nDotPos2=`exprGindex"$name""$2"`nwhileG["$DotPos2"-gt"0"]ndoDotPos1=`exprG$DotPos1+$DotPos2`DotPos2=`exprG$DotPos2+1`name=`substringG"$name"$DotPos2999`DotPos2=`exprGindex"$name""$2"`ndonenechoG$DotPos1 }html: html: extension() {GDotPos=`lastindex"$1""."`nifG["$DotPos"-gt"0"]nthen%substringG"$1"`expr$DotPos+1``stringlen"$1"`nelseechoG""nfi }html: html: #Kmainloop-findfilestobemodified findG.-print\0ۺcolor push BlackG30Ff color popZОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hj|Gwhilereadi 3)pdoifG[-f"$i"]&&[-r"$i"]thenifG[-w"$i"]then uifG["`extension$i`"="c"]||\[G"`extension$i`"="h"] uthenifGgrep'//'$i>>/dev/nullthen R6echoG"File$iismodified." R6mvG"$i""$i"~ R6substG"$i"~>$ifi ufielse uechoG"File$iisnotwritable!"fifi)pdoneۺhtml: html:# 3.7.dRtab\#ellenverwerkendRmetawkhtml: html: Descripttaalhtml: html:awk(klinktalshtml: html:`lookGawk`)isgenoGemdnaarhaarmakers,Aho,W*einbGergerenKernighanvqanA,T &T.A*wkisuitgebreiderdansedenvoGoralgeschiktvoGorhetverwerkenvqantabGellen.V*eelUnixcommando'sals ls,ps,enwhoproGducerentabellen,plattetekstlesbestaaandeuitkolommenmeteenvqastebreedte.Desyntaxis luidt:@html: html:html: html: awk@html: html:U [html: html:optie...]html: html:[-fhtml: html:sfile]html: html:html: html:'script'html: html:[html: html:file...]html: html: DeSbGelangrijksteoptieishtml: html:-Fhtml: html:t,waarmeehettekenhtml: html:tmalshtml: html:eldseparatorwordtingesteld.Hetscriptzelfkqanweerals een html:-f,enalsergeenverdere lenamenn#zijnmeegegeven,danzalawkdestandaardinvoGerverwerken.A*wkscriptshebbGenoverhetalgemeende vorm html: html: 3 [html: html:BEGING{html: html:actie}] [html: html:patroon]G[{html: html:actie}] ... [html: html:ENDc{html: html:actie}]html: html: NetalsbijsedzalelkeinvoGerregelnvoGornmetdepatronenwordenvergelekenenvoGorelkpatroondat overeenkomtzaldebijbGehorendeactiewordenuitgevoGerd.Alsergeenpatroonisopgegevenwordtdeactiealtijd uitgevoGerdenalsergeenactiestaat,danwordtdeinvoGerregelafgedrukt.DeeventueleactieachterbGeginwordt voGor=hetinlezenvqandeeersteregeluitgevoGerdendeactieachterendnaheteindvqandelaatsteregel.Heteerste voGorbeeldU verwijdertlegeregelsuitdeinvoGer:html: html:awk'$0'html: html: X Hierinestaathtml: html:$0voGordeinvoGerregel.DeinvoGerregelwordtdoGorawkgesplitstinvelden,gescheidendoGorwitruimteof een@anderscheidingsteken,@genaamdhtml: html:$1,html: html:$2,....@html: html:NF4ishetaantalveldenenhtml: html:NR4hetaantalrecordsc.qregelnummer. HetU toGevoegenvqanregelnummersaandeinputgaatmetawkeenvoudigerdanmetsed:html: html:awk'{printNR""$0}'0ۺcolor push BlackG31Ff color pop Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍jaf荑ۺc/html: html: DepatronenkunnenbGoolesecombinatiesvqanreguliereexpressieseno/ofrelationeleexpressieszijn.DebGoolese combinatorennzijnhtml: html:!(niet),html: html:&&(en),html: html:||(of)endehtml: html:()haakjes;dereguliereexpressieszijneerderbGesproken;de relationeleYncombinatorenzijnhtml: html:<(kleiner),html: html:>(groter),html: html:<=(kleinerofgelijk),html: html:>=(groterofgelijk),html: html:==(gelijk),html: html:!= (ongelijk),U html: html:~(komtU overeenmetreguliereexpressie)enhtml: html:!~(komtnietovereenmetRE).html: html: ( ExpressieskunnenverderbGestaanuitvqariabelen,numeriekeconstanten(gehelegetallenofdrijvendekomma)en stringTconstanten(tussendubbGeleaanhalingstekens)enderekenkundigeopGeratorenhtml: html:+(optellen),html: html:-(aftrekken),html: html:* (vermenigvuldigen),Vhtml: html:/(delen),html: html:%(rest),html: html:^ofhtml: html:**(machtsverheen),html: html:++(1optellen)enhtml: html:--(1aftrekken)alsinde programmeertaalU CendestringopGeratorhtml: html:''(samenvoeging).html: html: ( Behalvelenkelvoudigepatronenkunnennetalsbijsedreeksenregelswordenopgegevenmeteentweetalpatronen. DeU volgenderegelselecteertderegels10to/mU 20vqaneenbGestand.html: html:awk'FNR==10,FNR==20'/etc/hostshtml: html: ( EenVawkscriptkqanoGokvariabGelenaanmaken;declarerenisnietnodig.EenvqariabelekqanzowelValsstringalsgetal worden?gebruiktenwordtautomatischgenitialiseerdmetwaardenhtml: html:0enhtml: html:"".DeopGeratorenbepalenhettypevqan hetnresultaat:zoleverthtml: html:("3x"G+1)n4opmaarhtml: html:("x3"G+1)n1.BehalveeenconstantetussenschuinestrepGenkqanook eenevqariabGelealsreguliereexpressiewordengebruikt.Deeenvoudigsteactieszijnhtml: html:html: html:variabeleE=Ghtml: html:expressieenhtml: html:print html: html:expressie.U HetisoGokmogelijkomdehtml: html:veldvqariabelen$1,$2,...eenU anderewaardetoetekennen.{html: html: MoGderne0awkvqariantenkennenassoGciatievearrays.ArrayshoGevennietgedeclareerdteworden:hetisvoldoGende een(elementvqaneenarrayeenwaardetegevenmethtml: html:html: html:naam[Ghtml: html:index]=html: html:waarde.(V*oGordeindexkunnengehelegetallen ofʪwillekeurigestringswordengebruikt,zelfsmeerderegetallenzijntoGegestaanompseudo-multidimensionalearrays teU maken.DewaardenvqandeindexhoGevennietopGeenvolgendtezijn.html: html: X A*wkU kenteenaantalrekenkundigefuncties.@html: html:html: html:html: html: 荍color push Black.xtcrm0800ـ color popsin(x)&bGerekentU desinusvqanx,metxinradialen荍color push Blackـ color popcos(x)&bGerekentU decosinusvqanxcolor push Blackـ color popexp(x)&bGerekentU dee-machtU vqanxcolor push Blackـ color popint(x)&bGerekentU deentiervqanxcolor push Blackـ color poplog(x)&bGerekentU denatuurlijkelogarithmevqanxcolor push Blackـ color popsqrt(x)&bGerekentU dewortelvqanxcolor push Blackـ color poprand&bGerekentU eentoevqalsgetaltussen0en1color push Blackـ color popsrand(x)&maaktU xtotgeneratorvqaneenreekstoGevalsgetallenۺhtml: html: A*wkU kentverschillendestringfuncties.@html: html:html: html:html: html: 荍color push Blackـ color popgsub(r,s,t)&vervqangtU indestringtoveraldesubstringrdoGorsenretourneerthetaantalhmalenU datdesubstitutieisuitgevoGerd荍color push Blackـ color popindex(s,t)&retourneertU depGositievqansubstringtinsof0isdienietisgevonden荍color push Blackـ color poplength(s)&retourneertU delengtevqandestringcolor push Blackـ color popsubstr(s,p,n)&retourneertU desubstringvqans,vanafpGositiepvanntekenslangcolor push Blackـ color poptolower(s)&retourneertU smetallehoGofdlettersvervqangendoorkleinecolor push Blackـ color poptouppGer(s)&retourneertU smetallekleinelettersvervqangendoGorhoofdlettersۺhtml: html: A*wk;lijkteenbGeetjeopC.Actiesc.q.statementswordengegroGepeerd;dooraccoladesenafgeslotendooreenpun- tkommaZofnieuweregel.EenlangstatementkqanwordenvoGortgezetdoorderegelmeteenbackslashtebeindigen. Na*eenhtml: html:#hekjewordtderestvqanderegelalscommentaarbGeschouwd.Hethtml: html:if-statementheeftdevolgendesyntaxis. html: html:html: html: if(Ghtml: html:expressieE)html: html:statement1[html: html:elsehtml: html:statement2]0ۺcolor push BlackG32Ff color pop!Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍hjAlsգdeexpressieongelijkisaan0c.q."",danwordtheteerstestatementuitgevoGerdenandershetoptioneletweede. V*oGorU herhalingbestaanertweeU vqariantenvqanwhileendehtml: html:for-lus.ۺ html: html: html: html: 3 while(Ghtml: html:expressie)html: html:statement{html: html: doGhtml: html:statementEhtml: html:while(html: html:expressie)html: html: for(Ghtml: html:expressie1;html: html:expressie2;html: html:expressie3)html: html:statementhtml: html: Deeersteexpressieachterforinitialiseertdelus,detweedetestofdelusbGeindigdmoetwordenendederdewordt naelkedoGorganguitgevoGerd.Omtottientetellengebruikjehtml: html:awk'BEGIN{}{}END{for(i=1;i<=10;i++) printU i}'html: html: ( DeU volgendevormvqandefor-lusloGoptalleelementenvqaneenarrayaf: html: html:html: html: forG(html: html:variabeleEhtml: html:inhtml: html:array)html: html:statementhtml: html: Methtml: html:breakkqaneenlusvoGortijdigwordenverlaten;methtml: html:continuewordtderestvqandeinhoudvandelusovergeslagen en`methtml: html:exitwordtderestvqandeinvoGerovergeslagenengaatawkverdermetdeeventueleactieachterhtml: html:end;inde end-sectieU kqanweereenhtml: html:exitopGdrachtvolgenmeteenexitstatus.html: html: X InU moGderneversiesvqanawkkunnenineenscripteigenfunctiesgedenieerdwordenmet html: html:html: html: functionGhtml: html:naam(html: html:parameter1,...){html: html:statementsE}html: html: F*unctieswcmoGetenwordengedeclareerdvoGordatzekunnenwordengebruikt.Metdehtml: html:returnopGdrachtkunnenzeeen waardeteruggeven.Alsineenfunctiedewaardevqaneenparametergewijzigdwordt,danzalditgeeneekthebbGen opU dewaardevqaneenvariabGelediealsargumentismeegeven,bGehalvevoGorarrays.html: html: X HetU ismogelijkommethtml: html:printnaareenwillekeurigeleteschrijvenmetdenotatie html: html: html: html: 3 printGhtml: html:waardeE>"html: html:file" ZonderdeaanhalingstekensisleeenvqariabGelediedenaamvanhetbGestandbevqat.Omdeuitvoerachterde bGestaandeU inhoudvqanhetbestandteplakkenwordthetvolgendegebruikt: html: html:html: html: printGhtml: html:waardeE>>"html: html:file" HetvisoGokmogelijkombinneneenawkscripteenexterncommandotestartendatdeuitvoGervqanprintleestmet deU notatie html: html:html: html: 3 printGhtml: html:waardeE|"html: html:commando" OmU deoutputvqaneenexterncommandointelezenkunjeietsalshtml: html:system("html: html:commando"|getline)gebruiken.html: html: ( OmU nettetabGellentemakenwordthethtml: html:printf0statementgebruiktmetdevolgendesyntaxis: html: html:html: html: printfG"html: html:formaat",html: html:expressie1,...html: html: DeYformaatstringwordtgewoGonafgedrukt,afgezienvqanformaatspecicaties,diewordenvervqangendoGornvan devolgendeexpressies.AndersdanvoGorprintmoGetdeformaatstringwordenafgeslotenmeteenregeleinde(html: html:\n).0ۺcolor push BlackG33Ff color pop"ӠОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍UDEenformaatspGecicatiegeeftaaninwelkformaatdebijbehorendeexpressiemoetwordenafgedruktenheeftde vorm3%[-][0][breedte[.html: html:precisie]]html: html:typeۺhtml: html: De'expressiewordtafgedruktinhtml: html:breedte∺kolommen,mitshetdaarinpast,eneventueelaangevuldmetspaties, maaralsdebreedtemet0bGegint,wordenervoGorloopnullengebruikt.Eeneventueelmin-tekengeeftaandatde waarde?linksmoGetwordenaangelijnd.V*oGorgetallengeeftdehtml: html:precisiedhetaantalcijfersachterdekommac.q. decimaleKpuntweer;voGorstringsisdatdelengtewaaropdestringwordtafgekqapt,waarnahetresultaatwordt aangevuldutotdeopgegevenbreedte.HetafkqappGenvanrelevanteinformatiekaneenbugineenscriptvormen.De volgendeU formaattypGenzijnmogelijk.@html: html:html: html:html: html: 荍color push Blackـ color pop%%&eenU enkelproGcentteken荍color push Blackـ color pop%c&eenU enkellettertekencolor push Blackـ color pop%c&eenU enkellettertekencolor push Blackـ color pop%s&eenU stringcolor push Blackـ color pop%d&eenU geheelgetal;breukenwordennietafgerondcolor push Blackـ color pop%o&eenU pGositiefgeheelgetalinoctalestelselcolor push Blackـ color pop%x&eenU pGositiefgeheelgetalinhexadecimalestelselcolor push Blackـ color pop%f&eenU decimalebreukcolor push Blackـ color pop%e&eenU getalindrijvende-kommaU notatiecolor push Blackـ color pop%g&deU bGestleesbarenotatievoorhetgetalۺhtml: html: ZoU zullendevolgendeopGdrachten@html: html:html: html: {Gprintf"%10.3s\n",3.1415692} 3 {Gprintf"%10.3f\n",3.1415692} alsU outputgeven: html: html:-3.1#c3.142html: html:# 3.8.dRexp\#ectenanderescripttalenShtml: html: DebGehandelingvqanawkishiervrijkortgehoudenondanksdevrijcomplexematerie.Declouisdateenvqande bGelangrijksteH%redenenomawkbinneneenshellscripttegebruiken,deprintffunctie,oGokindekornenbGourne againshellsisingebGouwd.OokdeanderescripttalenalsPerl,TCL,PHP3enPython,zijnteuitgebreidomhier te0bGehandelen.Perllijktenigszinsopawk,metnogmeermogelijkheden.TkmaaktincombinatiemetTCL0ofPerl GUIU scriptsmogelijk.html: html: X C~programmeursgebruikenmakeles,dieaangevenwelkesourcelesmetwelkeoptiesmoGetenwordengecompileerd omebinariesenlibrariestemaken.MakelesbGevqattenweershellcommando's.Dem4macroproGcessoriseengevqal apart,UdattevergelijkenUismetdeCUpreproGcessor,enhandigisvoorassemblyprogrammeurs.Eenm4lekqan willekeurigeU tekstbGevqattenplusmacrodenitiesenmacro's.M4vervqangtdandemacro'sdoorhundenitie.html: html: X Postscript€fvqanf\AdobGewordteenpaginabGeschrijvingstaalgenoGemd.Postscriptprogramma'swordengeschreven doGorzopmaakprogramma'senuitgevoerddoorprinters,resulterendineenofmeerpagina'sgedrukttekst.Elementen0ۺcolor push BlackG34Ff color pop#LОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjdieopelkepaginaterugkomenwordeneenmaligalseenfunctiegedenieerd.V*erderheefthetwatvqanF*orthweg. HetU voGordeelisdatdetaalonafhankelijkvqanhettypGeprinteris.ۺhtml: html: X Om\eenscriptteschrijven\datinteractie,zowelin-alsuitvoGer,pleegtmeteenanderprogramma,kunjegebruik makenvqanhtml: html:html: html:ExpGect,(http://expGect.nist.gov)datweergebruikmaaktvqanJohnOusterhout'sT*oGolCommandLan- guage.U Desyntaxisluidt@html: html:html: html: expGect@html: html:U [-di]html: html:[-chtml: html:script]html: html:[-fhtml: html:sfile]html: html:...html: html: Dehtml: html:-doptiegeefteenhoGopdiagnostischeuitvoGer.Metdehtml: html:-ioptiegedraagtexpectzichalseeninteractieveshell. Achterhtml: html:-ckqanineenheelscript(tussenaanhalingstekens)wordenopgegevenenmethtml: html:-fkqandenaamvandele met`hetscriptwordenmeegegeven.HierondervolgteenvoGorbeeld`waarinexpGectwordtgebruiktomeenbGestand teU downloadenviaftp,watmetdeshellnietzoulukken.html: html:html: html:html: html: (Khtml: html:#!/usr/bin/expectG-f 3html: html: #Kzoalsaangegeveninparagraaf1.3wordthierboven #Kexpectgestartenderestzijnexpectcommando's spawnGftplocalhost18html: html:#KMetspawnwordteenexternprogrammagestart expectG-re"Connected.*\n" expectG-re"220.*\n" expectG-re"Name.*:.?"18html: html:#KHetexpectcommandolaatexpectwachtentotdathet #Khetexterneprogrammadeopgegevenstringsuitprint #Kofereentime-outofend-of-fileoptreedt. #KNade-reoptievolgteenreguliereexpressie. #K\nstaatvooreennieuweregelen\rvoorreturn. sendG"anonymous\r" expectG"anonymous\r\n"18html: html:#KHetsendcommandostuurtdeusernaamnaarhetftp #Kproces.Datzaldeinvoerterugechoen. expect n{;(-reG331.*\nPassword:{'expect_userG-re.*\n1}6q}18html: html:#KWewachtenopdepassword-promptvandeftpserver #Kendanvraagthetscriptdegebruikeromzelf #Khetwachtwoordintevullen. sendG"$expect_out(0,string)\r" expectG"\r\n"18html: html:#KWesturendeinvoervandegebruikernaardeftp #Kserver.Diezalhetwachtwoordnietlatenzien. expect n{0ۺcolor push BlackG35Ff color pop$Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hj u-reG(230.*\n)+.*\n.*\n n{} 3 u-reG(530.*.n)+.*\nKexit u}} uhtml: html:#KNuzijnertweemogelijkheden:230.Useranonymous#Kloggedin,of530.Loginincorrect;inheteerste#Kgevaldoenwenietseninhettweedegevalstoppen#Kwedeexpectsessie.expectG-re"ftp>.?"sendG"cdpub\r"expectG"cdpub\r\n"expectG-re"(250.*\n)*250.*successful.*\n" uhtml: html:#KWewachtenopdeftppromptensturen"cdpub"expectG-re"ftp>.?"sendG"ls\r"expectG"ls\r\n"expectG-re"200.*\n150.*\ntotal(.*\n)+226.*\n" uhtml: html:#KWesturen"ls"enkrijgeneenaantalregelsterug,#Kennadepromptsturenwe"getREADME"expectG-re"ftp>.?"sendG"getREADME\r"expectG"getREADME\r\n"expectG{r)-reGlocal.*\n200.*\n150.*\n226.*\n.*received.*\n{}r)-reGlocal.*\n200.*\n550.*\nlwaexit}DeU restvqandithoGofdstukwordtbesteedaaneenkortebeschrijvingvqanenkelehandigehtml: html:Unixcommando's.ۺhtml: html:! 3.9.dRatenbatchhtml: html: DeU html: html:atfaciliteitzorgtervoGordatopdrachtenU opeenlatertijdstipwordenuitgevoGerd.Desyntaxisluidt:@html: html:html: html: X at@html: html:U [-m]html: html:[-l]html: html:[-fhtml: html:file]html: html:[-qhtml: html:letter]html: html:[-rhtml: html:job]html: html:html: html:tijdstiphtml: html: Dehtml: html:-foptiewordtgevolgddoGordenaamvqanhetuittevoGerenscript;alsdezeoptieontbreekt,danworden commando'svqandestandaardinvoGergelezen.DeuitvoervqanhetscriptwordtdegebruikertoGegemaild,dusdie hoGeftophetmomentvqanuitvoGeringnietingelogdtezijn.Opdemeestesystemenhebbenookgewonegebruikers toGestemmingU omattegebruiken.html: html: X Deghtml: html:-moptiezorgtervoGordaterookmailwordtverzondenalsdeopGdrachtgeenuitvoGerproduceerde.ErwordtvoGor gezordU datdecommando'sdezelfdeomgevingsvqariabGelenmeekrijgenalsophetmomentdatatwerdaangeroGepen.html: html: X Het<html: html:batchcommandodoGethetzelfdealsat,behalvedatcommando'spaswordenuitgevoGerdwanneerdebGelasting vqanhetsysteemvoldoGendelaagis.Diebelastingkrijgjetezienmethtml: html:uptime.Dehtml: html:-qvlaggeeftaaninwelkequeue (wachtrij)rdejobterechtrkomt.DequeuebGepaaltdeprioriteitwaarmeeeentaakwordtuitgevoGerd:html: html:aisdedefault atU queue,html: html:bdedefaultbatchqueue.html: html:0ۺcolor push BlackG36Ff color pop% Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍*@*Dejtijdkqanwordenopgegevenalshtml: html:uummJofhtml: html:uu:mm,desgewenstmethtml: html:amofhtml: html:pmerachter.DeliefhebbGermagookhtml: html:now, html: html:midnight,6khtml: html:noonofhtml: html:teatimegebruiken.Daarachterkomtdeeventueledatum,diebijvoGorbeeld6khtml: html:todayofhtml: html:tomorrowmagluiden.cAlshettijdstipalvoGorbijis,wordtaangenomendathetmorgenmoGetzijnenalsdedagalgeweestis,danzalU degebruikerwelvolgendjaarbGedoelen.U EnkelevoGorbeelden:@html: html:ۺhtml: html: atG0815amJan24,2002 3 atG8:15amJan24 atGnow+1day atG5pmFridaynextweekhtml: html: Met dehtml: html:-loptiekrijgjeeenlijstvqandegeplandetakentezien.Metdehtml: html:-roptiekunjeeentaakverwijderen.Alleen html: html:rootU magandermanstakenannuleren.html: html:! 3.10.dRcronhtml: html:html: html: Croniseenhtml: html:Unixdaemon,eensysteemprogrammadatopdeachtergrondloGopt,dieopgezettetijdenopgegeven programma'sstart,terwijlatvoGoreenmaligeopdrachtenis;opsommigesystemenstartcronelkeminuuteen programma^datkijktofernogatjobstedoGenzijn.Cronwordtmeestalgebruiktdoordesysteembeheerderom bijvoGorbeeldU 'snachtsbackupstedraaien,maarisvqaakoGokvoGordeanderegebruikersbGeschikbaar.html: html: X NetalsatzalcroneventueleuitvoGervqaneenopdrachtnaardeopGdrachtgevermailen,tenzijjedestandaarduitvoGer omleidt;}EerwordtdoGorgaanseenregelineenloglegeschrevenvoGoruitgevoGerdejobs.Eennadeelvqancronisdat taken=dienietophetaangegeventijdstipuitgevoGerdkunnenworden,bijvoGorbeeld=omdatdecomputerdownis, zullenwwordenovergeslagen.EenanderverschilmetatisdatjedeomgevingsvqariabGelenmistdiewordeningesteld alsU jeinlogt.html: html: X Degebruikermaaktgebruikvqandehtml: html:crontabopGdrachtomzijn/haarlijstmetcrontakentewijzigen.Desyntaxis luidt:@html: html:html: html: cron@html: html:U [-uhtml: html:user]html: html:[html: html:-ehtml: html:|-lhtml: html:|-r]html: html: De.verticalebalkhtml: html:|geeftinonzesyntaxis-notatieaandathtml: html:of>dehtml: html:-evlag,html: html:ofhtml: html:-lhtml: html:ofhtml: html:-umoGetenwordengebruikt:udient het =evenminalsderechterhakenovertetypGen.Metdehtml: html:-uoptiekqanrootandermanscrontabelwijzigen;dezeoptie kqan-0oGokhandigzijnincombinatiemethtml: html:su.Metdehtml: html:-roptiewordteencrontabGelverwijderd.Metdehtml: html:-eoptiewordt decrontabGelgewijzigd;voorditdoelwordthtml: html:viopgestarttenzijdeinhoudvqandeomgevingsvariabGelehtml: html:$EDITOR ietsU andersvermeldt.html: html: EencrontabGelbestaatuiteenaantalregels,dieafgezienvqanblancoofcommentaarregelseenzestalveldenbGezitten. html: html:html: html:html: html: 荍color push Blackـ color popminuut&(0o-59)荍color push Blackـ color popuur&(0o-23)color push Blackـ color popdatum&(1o-31)color push Blackـ color popmaand&(1o-12)color push Blackـ color popdag&(maandago=0,U zondag=0of7)color push Blackـ color popopGdracht&(gewoneU /bin/shcommandoregel)ۺhtml: html: DeUdagvqandeweekhtml: html:ofdedagvandemaandmoGetenovereenkomen;UhetvolgendevoGorbeeldUzalopelkevrijdagde 13html: html:e_ltussenelfuurenmiddernachtelkeminuutdeinhoudvqandehtml: html:/tmpdirectorywissenhtml: html:enop13novembGerongeacht0ۺcolor push BlackG37Ff color pop&dОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjde|&dagvqandeweek.IndeplaatsvaneengetalmogenermeerderevoGorkomen|&metkomma's,maarzonderspaties ertussen.@html: html:ۺhtml: html: 3html: html: #Keenvoorbeeldcrontabel *G2313115find/tmp-execrm-f{}2>/dev/nullhtml: html:# 3.11.dRbasenameendirnamehtml: html: Het )html: html:basenamecommandoverwijderthetdirectorypaduiteenlenaameneventueeldehtml: html:extensie.Desyntaxisluidt: html: html:html: html: basename@html: html:U html: html:padnaamhtml: html:[html: html:extensie]html: html: AlsdelenaamnieteindigtopdeextensiedanwordtdehelenaamweergegevenenoGokalsdelenaamgelijkis aandeextensie.Dieextensiekqaneenwillekeurigestringzijn.ErwordtnietgecontroleerdofdelebGestaat.Het volgendeU voGorbeeldgeeftdevoornaamvqanallehtml-bestanden.@html: html:html: html: forGfilein`find.print|fgrep.html` 3 donbasenameG$file.html donehtml: html: HetU html: html:dirnamecommandogeefthetdirectorypadvqaneenlenaam.Desyntaxisluidt:@html: html:html: html: X dirname@html: html:U html: html:padnaamhtml: html: Alswergeenslash(html: html:/)indepadnaamvoGorkomt,wwordtdehuidigedirectory(html: html:.)geretourneerd.HetvolgendevoGorbeeld geeftalledirectory'sdiehtml-bGestandenbevqatten,metdienverstandedatalleendenaamennietdeinhoudvande leU wordtgetest.@html: html:html: html: findG.-print|fgrep.html|xargs-l1dirname|uniq-chtml: html:# 3.12.dRclearhtml: html: Hetҁcommandohtml: html:clearwistdeinhoudvqanhetschermenzetdecursorindelinkerbGovenhoek.ҁDeomgevingsvqariabGele html: html:TERMU bGevqathettypevqanuwterminal;alsclearnietwerkt,kijkofuwterminalwordtondersteund.html: html:0ۺcolor push BlackG38Ff color pop'3Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hj3.13.dRsortenuniqۺShtml: html: Met,html: html:sortkunnenbGestandenwordengesorteerdeno/of,samengevoGegd.DesorteervolgordewordtbGepaalddoorde ingesteldeU taalendestandaardinstellingisdatdeheleregelalssorteersleutelwordtgebruikt.Desyntaxisluidt:@html: html:html: html: X sort@html: html:U [-c]html: html:[-m]html: html:[-u]html: html:[-thtml: html:teken]html: html:[+html: html:pos1html: html:[-html: html:pos2]]html: html: ( [U -ohtml: html:file]html: html:[-Thtml: html:directory]html: html:[le...]html: html: DeU volgendeoptieszijnmogelijk:@html: html:html: html:html: html: -cU (check)html: html:( color push BlackU color pop html: html:U alleencontrolerenofdeinvoGerreedsgesorteerdis html: html:html: html: -mU (merge)html: html:( color push BlackU color pop html: html:U samenvoGegenvqanbestandendiereedsgesorteerdzijn html: html:html: html: -uU (unique)html: html:( color push BlackU color pop html: html:U neemidentiekeU regelsslechtsU nkeeropindeuitvoGer html: html:html: html: -tU (tab)html: html:( color push BlackU color pop html: html:hhetvolgendetekenwordtgebruiktomveldentescheiden;gebruikeentekendatnietindeinvoGervoGorkomt alsyupuuroppGositiewildtsorteren.Standaardwordentabsenspatiesgebruiktomveldentescheidenenna eenU spatiewordenvolgendespatiesalsdeelvqaneenveldbGeschouwd. html: html:html: html: -oU (output)html: html:( color push BlackU color pop html: html:,khiermeewordtaangegevennaarwelkbGestanddeuitvoGerwordtgeschreven;deuitvoGermageeninvoGerbestand overschrijven html: html:html: html: -TU (tempGorary)html: html:( color push BlackU color pop html: html:U hiermeekqandedirectoryvoGortijdelijkebGestandenwordenopgegevenhtml: html: V*erderkqanwordenopgegevendatdeveldenvqanafhtml: html:pos1totenzonderhtml: html:pos2desorteersleutelvormen.Alshtml: html:pos2 ontbreektoJdanvormtdehelerestvqanderegeldezoGeksleutel.Erwordtgeteldvqanaf0.Regelswaarvqandeeerstehtml: html:i veldenSgelijkzijnwordengesorteerdopbasisvqanhethtml: html:i|+1html: html:/J aeitt10ewveld.SDepGositieskunnenvqandevormhtml: html:m.n zijn,waarin html: html:mhetveldnummerisenhtml: html:ndepGositiebinnenhetveld.DevolgendeoptieszijnglobaalgeldigalszevoGorhtml: html:pos1staan, maarU alszeachterU eenpGositiestaanhebbenzebetrekkingopdatveld.@html: html:html: html:html: html: -bU (blanks)html: html:( color push BlackU color pop html: html:U negeervoGorloopspaties html: html:html: html: -dU (check)html: html:( color push BlackU color pop html: html:U alleenletters,cijfersenspatieszijnbGepalendvoordevolgorde html: html:html: html: -iU (ignore)html: html:( color push BlackU color pop html: html:U negeertekensdieniettothet7-bitshtml: html:ASCIGIalfabetbehoren html: html:html: html: -fU (fold)html: html:( color push BlackU color pop html: html:U veranderhoGofdlettersinkleineletters;hoofdlettersverschijnenU welgewoGonindeuitvoGer0ۺcolor push BlackG39Ff color pop(@1Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: -nU (numeric)html: html:( color push BlackU color pop html: html:WdeinvoGerWsorterenopgetalswaardei.p.v.alfabetischevolgorde;ditmaaktdehtml: html:boptieautomatischaktief.De invoGerU moetrechtsaangelijndzijn,watmethtml: html:printfkqan,ziecolor push gray 0html:paragraaf3.7 html: color pop. html: html:html: html: X -rU (reverse)html: html: color push BlackU color pop html: html:U sorteerinomgekeerdevolgordehtml: html: Het!pvolgendevoGorbeeld!psorteerthetwachtwoGordbestand!pophtml: html:GroupID! html:UserIDs inomgekeerdevolgordegezetenpGerUIDophethtml: html:html: html:GCOSaliascommentveld,datvqaakdevolledigenaamvqande gebruikerU enevt.kqamernummerentelefoGontoestelU bevqat.@html: html:html: html: sortG-bdft:+3n+2nr-5/etc/passwdhtml: html: HetXhtml: html:uniqcommandokqaninveelgevallenwordenweggelatenenhtml: html:`sort-u'wordengebruiktomdubbGeleregelste verwijderen.U Desyntaxisluidt:@html: html:html: html: X uniq@html: html:U [html: html:-uhtml: html:|-chtml: html:|-d]html: html:[-html: html:kolommen]html: html:[+html: html:tekens]html: html:[html: html:inhtml: html:[html: html:uit]]html: html: Dehtml: html:-uoptiezorgtervoGordatenkelderegelsdienietdubbGelvoGorkomenwordenafgedrukt,terwijldehtml: html:-doptieelke vqakervoGorkomenderegeleenkeerindeuitvoGerverschijntenmethtml: html:-cwordenalleregelsvoGorafgegaandoorhetaantal kerenU datzevoGorkomen.html: html: Achter{ hethtml: html:-tekenkomteeneventueelaantalkolommendatvoGordevergelijkingwordtovergeslagen;achterhethtml: html:+ tekenU komteenaantaltekenpGositiesdatwordtovergeslagen,nadatdevoGorafgaandekolommenzijnovergeslagen.html: html: X V*eelcommando'sgeveneersteentitelregel,diewenietmeewillensorteren.Inplaatsvqanhtml: html:head(ziecolor push gray 0html:Paragraaf3.17 html: color pop) enU html: html:tailtegebruikenkqanhetoGokmethetscriptje`knip'.@html: html:html: html: readGLINE 3 echoG"$LINE"1>&2 whileGreadLINE donechoG"$LINE" done Ditleidtdeeersteregelomnaarhetstandaarderrorkqanaal;nahetsorterenkunnenwebGeidekanalenweer samenvoGegen.U Hethtml: html:wcommandogeefteentabelvqaningelogdegebruikersmettweetitelregels.@html: html:html: html: wG|knip|knip|sort-f2>&1html: html:# 3.14.dRcmp,commendiShtml: html: MetU hethtml: html:cmpcommandokunnentweeU leswordenvergeleken.Desyntaxisluidt:@html: html:html: html: X cmp@html: html:U [html: html:-lhtml: html:|-s]html: html:html: html:file1html: html:html: html:file20ۺcolor push BlackG40Ff color pop)W=Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html: StandaardāwordthetnummerendeinhoudvqanheteerstebytegetoGonddatverschiltalsoGctaalgetal.Metdehtml: html:-s (silent)|optieisergeenuitvoGerenkqanslechtsdeexitstatuswordengetest,terwijlhtml: html:-lallebytesdieverschillenden weergeeft.html: html: X CmpIisgeschiktvoGorbinaireles;html: html:commvergelijkttweebGestandenregelvoGorregel.Debestandendienengesorteerd teU zijn.Desyntaxisluidt:@html: html:html: html: comm@html: html:U [-1]html: html:[-2]html: html:[-3]html: html:html: html:file1html: html:html: html:file2html: html: ZondervlaggenwordtdeuitvoGerweergegevenindriekolommen:indeeersteregelsdiealleeninle1voGorkomen,in deftweederegelsdieinle2voGorkomen,enindederdekolomdegemeenschappGelijkeregels.Dekolommenworden gemarkeerdUdoGorderegelmetnul,eenoftweetab-tekenstebGeginnen;deuitvoGerisnietbijsteroverzichtelijk.De vlaggen|gevendeoptieeenofmeerderekolommenwegtelaten,bijv.html: html:comm-12...'om|alleengemeenschappGelijke regelsU tezien.html: html: HetU html: html:di0commandozoGektnaardeverschillenU tussentweeU bestanden.Desyntaxisluidt:@html: html:html: html: di@html: html:U [-b]html: html:[-r]html: html:[-e]html: html:html: html:file1html: html:html: html:file2html: html: Met[deoptiehtml: html:-bwordenspatiesaanheteindvqaneenregelgenegeerd.Metdeoptiehtml: html:-rwordenalshtml: html:file1enhtml: html:file2 directory'szijnallelesindiedirectory'svergeleken.Metdeoptiehtml: html:-ewordtdeuitvoGerindevormvqancommando's voGorU dehtml: html:ededitor(grootvqadervanvi)geschreven.html: html: ( DȇuitvoGervqandikanwordengebruiktommethethtml: html:patchtoGolhtml: html:file1teverandereninhtml: html:file2ofandersom.Als eenfprogrammeuraaneengroGotprogrammaeenpaarregelsheeftveranderd,hoefthijo/zijfslechtsdepatchte verspreiden.U DeuitvoGervqandiheeftdevolgendevorm: html: html: n1aGn3,n4 nhtml: html:(regels$toAev html:(regels$v html:(regels$wijzigen)html: html: AchterNeeneditcommandovolgteenlijstvqandebGetroenregelsinhtml: html:file1mettelkenseenhtml: html: html:file2voGorafgegaandooreenhtml: html:>;bijv.alsindeeneleopregel13eenetsstaatwaardeandereeen rijwielU heeft: html: html: 13c13 3 <Gfiets --- >Grijwielhtml: html:# 3.15.dRcolumnhtml: html: Hetzcolumncommando(html: html:BSD,Linux)kqantekstinkolommenverdelenomeennetteuitvoGertegeven.Desyntaxis luidt:@html: html:html: html: column@html: html:U [-t]html: html:[-x]html: html:[-chtml: html:kolommen]html: html:[-shtml: html:teken]html: html:[html: html:file...]0ۺcolor push BlackG41Ff color pop*k.Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍hjDeU optieszijn:-cU (count)ۺhtml: html:( color push BlackU color pop html: html:hiermeegeefjedebreedtevqanhetschermop.IndemeestegevallenisdatnietnoGdigomdatdeomgevingsvari- abGeleU html: html:$COLUMNSdejuistebreedtebevqat. html: html:html: html: X -sU (separator)html: html: color push BlackU color pop html: html:U geefthetscheidingstekenU tussendekolommen(bijvhtml: html::voGorhtml: html:/etc/passwd) html: html:html: html: ( -xU (cross)html: html: color push BlackU color pop html: html:U vultdeuitvoGerregelvoGorregelopinplaatsvqankolomvoGorkolom html: html:html: html: X -tU (table)html: html: color push BlackU color pop html: html:U bGepaalthetaantalkolommenindeinvoGertekstinmaaktdezenetjesophtml: html: OpU devolgendemanierkqandeuitvoGervqanhtml: html:ndopeenls-achtigemanierinkolommenwordengezet.@html: html:html: html: findG.-mindepth1-print|xargs-l1basename|\ 3nsortG-u|columnhtml: html: InU hetvolgendevoGorbeeldU wordtdeuitvoGervqanhtml: html:lsvaneentitelregelvoGorzien.@html: html:html: html: (Gprintf\ 3n"PERMGLINKSOWNERGROUPSIZEMONTHDAYHH:MM/YEARNAME\n"n/bin/lsG-l|sed1d )G|column-thtml: html:# 3.16.dRcolrm,cut,paste,joinShtml: html: Hethtml: html:colrmcommandovqanhtml: html:BSDhtml: html:UnixverwijdertkolommenuitelkeregelvqandestandaardinvoGer.Metkolommen wordenU hiertekenpGositiesbedoeld.Desyntaxisluidt:@html: html:html: html: X colrm@html: html:U [html: html:startpositiehtml: html:[html: html:eindpositie]]html: html: DepGositieswordengeteldvqanaf1.Alsalleendestartpositiewordtopgegevenwordtderestvqanderegelverwijderd, andersU vqanstarttotenmeteind.html: html: SystemU Vhtml: html:UnixkentU eenhtml: html:cutcommandodatongeveerhetzelfdedoGet,metdevolgendesyntaxis:@html: html:html: html: X cut@html: html:U [html: html:-bhtml: html:|-chtml: html:|-f]html: html:html: html:lijsthtml: html:[-dhtml: html:teken]html: html:[html: html:file...]html: html: DeU optieszijnalsvolgt:@html: html:0ۺcolor push BlackG42Ff color pop+ƠОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: -bU (bytes)html: html:( color push BlackU color pop html: html:U dekolommenwordenopgegevenalsbyte-pGosities -cU (character)html: html: color push BlackU color pop html: html:L}dekolommenwordenaangegevenalstekenpGosities;inOostaziatischeenUnicoGdealfabettenkqaneenteken meerU daneenbytelangzijn html: html:html: html: X -fU (eld)html: html: color push BlackU color pop html: html:U dekolommenzijnveldengescheidendoGortabulatie-tekens html: html:html: html: X -dU (delimiter)html: html: color push BlackU color pop html: html:U geefteenalternatiefscheidingstekenU aan;alleentoGegestaanincombinatiemetdehtml: html:-foptiehtml: html: Achterdehtml: html:-b,html: html:-cofhtml: html:-foptievolgteenlijstmetveldnummersdieindeuitvoGermoetenwordenmeegenomen.Dit kqanȫeenreeksnummerszijn,gescheidendoGorkomma'szonderspatiesertussen.V*oGoreenenkelgetalkqanoGokeen bGereikqhtml: html:start-eind,ݺstaan,waarbijdestartofheteindookmogenwordenweggelatenomderestvqanderegelaan teU duiden.ZodoGendevolgendetweeregelshetzelfde@html: html:html: html: lsG-al|colrm4254 3 lsG-al|cut-b-41,55-html: html: DevolgendeopGdrachtendoGenniethetzelfde,omdatdeuitvoGervqanhtml: html:lsnietdoortabulatie-tekensgescheidenis,maar doGorU rijenspaties.@html: html:html: html: lsG-al|awk'{print$9}' 3 lsG-al|cut-f9-d''html: html: OmU heteektvqandeawkregeltebGereikendoGeje@html: html:html: html: lsG-al|sed-e's/[][]*//g'|cut-f9-d''html: html: Op&devolgendemanierkunjeeendirectorylistingsorterenopextensie,waarbijfunctiesuiteenvoGorbeeld&in color push gray 0html:ParagraafU 3.6 html: color popwordengebruikt.V*oGorbashisdeoptiehtml: html:-evereist.@html: html:html: html:html: html: #Koptioneelargument:directorynaam 3nlsG$1|whileread#cdo#cechoG-e"`extension"$REPLY"`""\t""$REPLY"%doneG|sort-df|cut-f2html: html: HetKomgekeerdevqancutishtml: html:paste.HiermeewordenregelsuitmeerderelessamengevoGegdtoteenregel,gescheiden doGorU tabs.PasteiswatbGeperkterU danhetjoincommando.Desyntaxisluidt:@html: html:html: html: X paste@html: html:U [html: html:[-s]-dhtml: html:lijst]html: html:html: html:file...0ۺcolor push BlackG43Ff color pop,EОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjDeU optieszijnalsvolgt:-dU (delimiter)ۺhtml: html:( color push BlackU color pop html: html:gebruikeenelementuitdelijstalsveld-scheidingstekens;erwordttelkenseenvolgendtekenuitdelijst gebruikt,U omaanheteindweerheteerstetenemen html: html:html: html: X -sU (serial)html: html: color push BlackU color pop html: html:U geefteenalternatiefscheidingstekenU aan;alleentoGegestaanincombinatiemetdeoptiehtml: html:-fhtml: html: HetU volgendevoGorbeeldU geefteenlijstbGestandenindriekolommen.@html: html:html: html: lsG|paste---|column-thtml: html: Met$html: html:joinwordentweetekstbGestandensamengevoGegd,dievoGorafgesorteerdmoetenzijn.Joinvoegtregelsuitbeide bGestandenvsamenmetdezelfdeinhoudvqanhethtml: html:sleutelveld.Hetsleutelveldisstandaardheteersteveld;velden wordenU gescheidendoGorspatiesoftabulatie-tekens.JoiniseenstandaardopGeratievoGordatabases.html: html: X DeuitvoGerbevqatalleveldenvanbGeidebestanden,enhetsleutelveldwordtmaarnkeergekopieerd.Alseen sleutelveldOindeeerstelehtml: html:n/keervoGorkomtenhtml: html:m/keerindetweede,danzaldeuitvoGerhtml: html:n=pm/regelsOmetdeze waardeU bGevqatten.Desyntaxisluidt:@html: html:html: html: join@html: html:U [html: html:-ahtml: html:filenrhtml: html:|-vhtml: html:filenr]html: html:[-ehtml: html:string]html: html:[-ohtml: html:lijst]html: html:[-thtml: html:teken]html: html: ( [html: html:U -jhtml: html:[html: html:filenr]html: html:veldnrhtml: html:|-1html: html:veldnr-2html: html:veldnr]html: html:html: html:file1html: html:html: html:file2html: html: JoinU bGeziteenaantalopties:@html: html:html: html:html: html: -aU (all)html: html:( color push BlackU color pop html: html:^proGduceerookeenregelindeuitvoervooriedereregelinhtml: html:filenrdiegeencorresponderenderegelinhet andereU bGestandheeft;html: html:filenriseenhtml: html:1ofhtml: html:2 8Phtml: html:html: html: ǰ -eU (empty)html: html:( color push BlackU color pop html: html:U vullegeveldenmetdeopgegevenstring html: html:html: html: X -jU (join)html: html: color push BlackU color pop html: html:U geefhetnummeropvqanhetveld,datalssleutelveldmoGetwordengebruikt;html: html:filenriseenhtml: html:1ofhtml: html:2 8Phtml: html:html: html: ǰ -1,G-2=html: html: color push BlackU color pop html: html:U html: html:-1iseensynomiemvoGorhtml: html:-j1enhtml: html:-2voGorhtml: html:-j2 whtml: html:html: html: -oU (output)html: html: color push BlackU color pop html: html:؁geefteenlijstvqanveldendieindeuitvoGermoetenkomen,wateencutbGespaart;eenveldwordtaangeduid metU html: html:filenr.veldnrenveldenwordengescheidendoGorkomma's 8Phtml: html:html: html: ǰ -tU (tab)html: html: color push BlackU color pop html: html:geeftaanwelktekenwordtgebruiktomdeveldentescheiden(helaasishtml: html:Unixnietergconsequentinde naamgevingU vqandeopties)0ۺcolor push BlackG44Ff color pop-Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: -vhtml: html: color push BlackU color pop html: html:proGduceeruitsluitendeenregelindeuitvoervooriedereregelinhtml: html:filenrVdiegeencorresponderenderegelin hetU anderebGestandheeft;html: html:filenriseenhtml: html:1ofhtml: html:2html: html: MetU bGehulpvqanjoinmakenweeenkortevqariantophetvoGorbeeldU vqancolor push gray 0html:Paragraaf2.9 html: color pop.@html: html:html: html:html: html: #Ksorteerdewachtwoordfileoploginnaam 3 sortGeenwhtml: html: #Kknipdetitelregelsuitlijstvangebruikers,K#Kscheiddeveldendoordubbelepuntensorteer wG|(read;read;cat)|sed-e's/[][]*/:/g'\ |Gsort>twee8html: html: #Kvoegdebestandensamenenmaakernettetabelvan (echoG"USER:FULLNAME:TTY";joineentwee-t':'\n-oG1.1,1.5,2.2)|column-t-s':';rm-feentweehtml: html:# 3.17.dRheadentailhtml: html: NaeenaantalopGdrachtendieveldenuitbGestandenmanipuleren,zijnernogeenpaardieregelsuittekstlteren. Naast)grephebbGenwehtml: html:headenhtml: html:taildierespectievelijkdeeersteendelaatstepaarregelsvqaneenbestandlatenzien; standaardU zijndattien(10)regels.Desyntaxisluidt:@html: html:html: html: ( head@html: html:U [html: html:-html: html:aantalhtml: html:|-nhtml: html:aantal]html: html:[html: html:file...]html: html: tail@html: html:U [html: html:[html: html:+html: html:|-]html: html:aantalhtml: html:[html: html:lhtml: html:|bhtml: html:|c]]html: html:[-f]html: html:[-r]html: html:[html: html:file]html: html: tail@html: html:U [html: html:-chtml: html:aantalhtml: html:|-nhtml: html:aantal]html: html:[html: html:file]html: html: DeU optieszijnalsvolgt:@html: html:html: html:html: html: X -nU (numbGer)html: html:( color push BlackU color pop html: html:U hetaantalregelsdatwordtweergegeven;ditishetzelfdealsdeoptiehtml: html:-aantal html: html:html: html: +html: html:aantal[l|b|c]8html: html:@ȍ color push BlackU color pop html: html:XalleenvoGortail;erwordtnuvqanafhetbGeginvandelegeteldinplaatsvanafheteind:ditishetzelfdealshtml: html:-n +html: html:aantal,U terwijlhtml: html:-nG-html: html:aantal㶺equivqalentismethtml: html:-nhtml: html:aantal㶺enheadgeentekenvoGorhetaantalkrijgthtml: html: de.optionelehtml: html:lachter.hetaantalbGetekentdaterregelsgeteldworden;alserhtml: html:cstaatwordenbytesgeteldeneen html: html:bU staatvoGordiskblokkenvqan512bytes html: html:html: html: -cU (character)html: html:( color push BlackU color pop html: html:U EenalternatievenotatievoGorhtml: html:+/-html: html:aantalc 8html: html:html: html: @ȍ -rU (reverse)html: html: color push BlackU color pop html: html:U deregelswordeninomgekeerdevolgordeafgedrukt;alleenvoGorhtml: html:BSDhtml: html:Unix0ۺcolor push BlackG45Ff color pop. Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: -fU (follow)html: html:( color push BlackU color pop html: html:laathetprogrammanietbGeindigenalsheteindvqanhetbestandisbereikt,maarkijktomdezoveelseconden ofU deleisgegroGeidendruktnieuweU regelsaf;handigvoorlogles.html: html: De7Chtml: html:GNU7 html:(read;read;cat).@html: html:html: html: 3[ headG-0* 3 tailG-n+3lhtml: html:# 3.18.dRsplitenddShtml: html: EenheelanderemanieromeenbGestandinregelstesplitsenishtml: html:split,datmeerdereoutputlesaanmaaktvqangelijke lengte.U Desyntaxisluidt:@html: html:html: html: X split@html: html:U [html: html:-html: html:[l]html: html:aantalhtml: html:|html: html:[-b]html: html:aantalhtml: html:[html: html:khtml: html:|m]]html: html:[html: html:filehtml: html:[html: html:prefix]]html: html: De!namenvqandeoutputlesbGeginnenmetdeopgegevenprex.Zonderprexhetenzehtml: html:xaa,Gxab,...!Deopties zijn:@html: html:html: html:html: html: X -lU (lines)html: html:( color push BlackU color pop html: html:geefthetaantalregelspGeruitvoGerle;deletterhtml: html:lmagwordenweggelaten;standaardwordenlesvqan1000 regelsU gemaakt html: html:html: html: -bU (bytes)html: html:( color push BlackU color pop html: html:Lmaaktlesmethetopgegevenaantalbytes;alserhtml: html:kachterstaat,wordenhetkilobytesenmethtml: html:mmegabytes: handigU alsdeuitvoGereenvqastegroottemoethebbenvoorbijvoorbeeldoppydisks.html: html: EenU gesplitstelekqanwordensamengevoGegdmethtml: html:catx*>html: html:file.html: html: De:functievqanhtml: html:ddwordtomschrevenals`convertandcopy',maaromdatccalbGestond,isvoGor`diskdumper' gekozen._HetwordtvoGoralgebruiktvoGordirektein-enuitvoGernaareenfysiekrandapparaat,omdathetnietregels maarU recordsmetvqastelengtekopieert.Desyntaxisluidt:@html: html:html: html: dd@html: html:U [html: html:optie=html: html:waarde...]html: html: ZonderU verdereargumentenlijkthetopcat,maarddkenteenrespGektabeleU lijstopties:@html: html:html: html:html: html: if=html: html:file{html: html: color push BlackU color pop html: html:U leesvqandeopgegevenlec.q.randapparaat html: html:html: html: of=html: html:filehtml: html: color push BlackU color pop html: html:U schrijfnaardeopgegevenlec.q.randapparaat0ۺcolor push BlackG46Ff color pop/ΗОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍bۺnMhtml: html:html: html: ibs=html: html:bytes[w|b|k]{html: html: color push BlackU color pop html: html:Tgeefthetaantalbytesdatinnkeergelezenwordt(recordgroGotte)op,standaard512bytes;alsachtervoGegsel kqanU deeenheidwordenopgegeven:eenwoGordistweebytes,eendisk-blok512bytes,eenkilobyte1024bytes html: html:html: html: X obs=html: html:bytes[w|b|k]html: html: color push BlackU color pop html: html:U geefthetaantalbytesdatinnkeerweggeschrevenwordt(recordgroGotte)op html: html:html: html: ( bs=html: html:bytes[w|b|k]html: html: color push BlackU color pop html: html:0Ngeefthetaantalbytesdatinnkeergelezenengeschrevenwordt;html: html:ibsenhtml: html:obswordengenegeerdalshtml: html:bsis opgegeven html: html:html: html: X cbs=html: html:byteshtml: html: color push BlackU color pop html: html:U geeftdegroGottevqandeconversie-buerU aanvoorconversieU naarofvqanhtml: html:IBMofhtml: html:EBCDICformaat html: html:html: html: X skip=html: html:recordswhtml: html: color push BlackU color pop html: html:U geefthetaantalrecordsdatvqandeinvoGerwordtgelezenmaarnietnaardeuitvoGerwordtgeschrevenhtml: html:html: html: seek=html: html:recordshtml: html: color push BlackU color pop html: html:U geefthetaantalrecordsindeuitvoGerledatwordtovergeslagenvoGordatddbegintmetkopirenhtml: html:html: html: iseek=html: html:recordshtml: html: color push BlackU color pop html: html:U netalshtml: html:skip,maarddspringtoverU derecordsheen,wattijdbGespaart whtml: html:html: html: oseek=html: html:recordshtml: html: color push BlackU color pop html: html:U netalsseek html: html:html: html: count=html: html:aantalhtml: html: color push BlackU color pop html: html:U kopieertslechtseenhtml: html:html: html:aantal㶺records html: html:html: html: files=html: html:aantalhtml: html: color push BlackU color pop html: html:U voGegteenaantalbGestandenmethtml: html:EOFertussensamen;alleenhandigvoGortape html: html:html: html: conv=html: html:code,...=html: html: color push BlackU color pop#U html: html: html: html:html: html: 荍#color push Blackـ color pop-ascii0converteerU vqanEBCDICnaarASCIGI荍#color push Blackـ color pop-ebGcdic0converteerU vqanASCIGInaarEBCDIC#color push Blackـ color pop-ibm0converteerU vqanIBMEBCDICnaarASCIGI#color push Blackـ color pop-bloGck0converteerU tekstbGestandmetregelsvqanvariabGelelengtenaarrecordsvancbsbytes doGorU regelsaantevullenmetspaties荍#color push Blackـ color pop-unbloGck0haalU spatiesaanheteindwegensluitregelafmetnewline#color push Blackـ color pop-lcase0vervqangU hoGofdlettersdoorkleineletters#color push Blackـ color pop-ucase0vervqangU kleinelettersdoGorhoofdletters#color push Blackـ color pop-swab0verwisselU evenenonevenbytes#color push Blackـ color pop-sync0alsU hetinvoGerU recordkleinerisdanibs,danwordthetaangevuldmetNULLbytes ofalsU deoptieblockgekozenisbytes#color push Blackـ color pop-noGerror0gaU doGoralsereenfoutoptreedt#color push Blackـ color pop-notrunc0maakU hetuitvoGerbestandnietleegalvorensernaarteschrijven0ۺcolor push BlackG47Ff color pop0Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍hjۺhtml: html: Demhtml: html:GNUmversiekentdeoptieshtml: html:files=,html: html:iseek=enhtml: html:oseek=niet.HetvolgendevoGorbeeldmmisbruiktddvoGorstring manipulatie.@html: html:html: html: echoG"Hello,world"|ddbs=1skip=7count=62>>/dev/nullhtml: html:# 3.19.dRenvhtml: html: HetYcommandohtml: html:enviseenaanvullingophtml: html:set,waarmeeeenomgevingsvqariabGelekanwordeningesteldvoGordeduur vqanU ncommando.Desyntaxisluidt:@html: html:html: html: X env@html: html:U [html: html:-html: html:|-i]html: html:[html: html:naam=html: html:waarde...]html: html:U [html: html:programmahtml: html:[html: html:argumenten]]html: html: EnvM6starthetprogramma,datdeopgegevennamenmetdebijbGehorendewaardenalsomgevingsvqariabGelenmeekrijgt. MetU deoptiehtml: html:-aliashtml: html:-iwordendebGestaandeomgevingsvqariabelenontzichtbaarU voorU hetprogramma.html: html: X Envd~zonderargumentengeeftdewaardevqanalleomgevingsvariabGelen,netalshetcommandohtml: html:printenv (zied~color push gray 0html:Paragraaf 3.28 html: color pop).html: html:! 3.20.dRexpand,unexpandentabsShtml: html: Expand(`iseenhulpmiddelomtabulatie-tekensineentekstbGestandtevervqangendoGorspatiesmetbehoudvqanpag- inaindeling.'ProgrammeursgebruikenhetbijvoGorbeeld'alseenprintertabsnietgoGedverwerkt.Unexpandvervqangt reeksenU spatiesdoGortab-tekens,watruimtebGespaart.Desyntaxisluidt@html: html:html: html: expand@html: html:U [-html: html:[t]html: html:tabstops]html: html:[html: html:file...]html: html: ( unexpand@html: html:U [html: html:html: html:-ahtml: html:|-t `html: html:tabstops]html: html:[html: html:file...]html: html: Positieswordengeteldvqanaf1.Standaardwordteentabstopomde8pGositiesaangenomen.Metdeoptiehtml: html:-tkqan eenanderewaardewordenopgegeven.HetisoGokmogelijkomdelijstvqantabstopsexplicietoptegeven,gescheiden doGor4komma's,alszeopongelijkeafstandenvoGorkomen.Unexpandvervqangtalleendespatiestotaanheteerste afdrukbareU teken,ofallesalsdeoptiehtml: html:-aisgespGeciceerd.html: html: In4uhtml: html:vikunjedetabstopszettenmethtml: html::setts=n;gerelateerdeinstellingenzijnhtml: html::setai(automatischinspringen)enhtml: html::set sw=html: html:m>(inspringdiepte).Omdetab-instellingentewijzigenopterminalsdieditondersteunenwordthetcommando html: html:tabsU gebruikt,metdesyntaxis:@html: html:html: html: tabs@html: html:U [html: html:-html: html:codehtml: html:|-html: html:nhtml: html:|html: html:n1,...]html: html:U [-Thtml: html:term]html: html:[+mhtml: html:n]html: html: ( tabs@html: html:U [-Thtml: html:term]html: html:[+mhtml: html:[html: html:n]]html: html:html: html:n1html: html:[,html: html:n2...]html: html: DeU optieszijnalsvolgt:@html: html:0ۺcolor push BlackG48Ff color pop1àОx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: -TU (terminal)html: html:( color push BlackU color pop html: html:U geefhetterminaltypGeop,alshtml: html:Unixdatnietindeomgevingsvqariabelehtml: html:TERMvindt +mU (margin)html: html: color push BlackU color pop html: html:geefdelinkermargeop;indetweedenotatiemaghtml: html:mzondergetalgebruiktwordenvoGordestandaardwaarde vqanU 10 html: html:html: html: -html: html:nhtml: html: color push BlackU color pop html: html:U geefeenrepGeterendetabstopop.IndetweedeU vormwordtdehtml: html:-weggelaten html: html:html: html:html: html: X n1,...=html: html: color push BlackU color pop html: html:U geefdelijstvqantabstopsexplicietophtml: html:html: html:html: html: codehtml: html: color push BlackU color pop html: html:AeenaantalsetstabstopszijnvoGorgedenieerd,bijv.html: html:-avoGorS/370assembler,html: html:-cvoGorCobol,html: html:-fvoorF*ortran, etc.html: html:# 3.21.dRlehtml: html: Het*7commandohtml: html:leonderzoGekthetbeginvqaneenleenprobeertdaaruitafteleidenwatvoGortypGebestandhetis. DitisietsbGetrouwbaarderdanopdeextensievqandelenaamaftegaan,maarhetblijftgissen.Alsuwsysteem eenU bGepaaldsoortdocumentnietherkent,kuntuzelfpatronentoGevoegenU aanhtml: html:/etc/magic.Desyntaxisluidt:@html: html:whtml: html: le@html: html:U [-c]html: html:[-fhtml: html:ffile]html: html:[-mhtml: html:mfile]html: html:[html: html:file...]html: html: DeU optieszijnalsvolgt:@html: html:html: html:html: html: X -cU (check)html: html:( color push BlackU color pop html: html:U controleerhetformaatvqandemagicle html: html:html: html: -fU (les)html: html:( color push BlackU color pop html: html:U onderzoGekdeleswaarvqandenameninhtml: html:html: html:ffile㶺staan {html: html:html: html: -mU (magic)html: html: color push BlackU color pop html: html:U leesdezoGekpatronenuithtml: html:html: html:mfile㶺inplaatsvqandestandaardlocatiehtml: html:# 3.22.dRfoldenfmthtml: html: F*oldU breektlangetekstregelsaf,zoGdatderestopdevolgenderegelterechtkomt.Desyntaxisluidt:@html: html:html: html: X fold@html: html:U [-bs]html: html:[-whtml: html:lengte]html: html:[html: html:file...]html: html: DeU volgendeoptieswordenherkend:@html: html:0ۺcolor push BlackG49Ff color pop2Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍hj-bU (backspace)ۺhtml: html:( color push BlackU color pop html: html:DdespGecialebehandelingvqanhtml: html:backspace,html: html:tabenhtml: html:carriagereturnwordtopgeheven,zoGdatzealsgewonetekens metU breedte1tellen html: html:html: html: -sU (spaces)html: html:( color push BlackU color pop html: html:U breekderegelafnaeenspatieinplaatsvqanmiddenineenwoGord html: html:html: html: X -wU (width)html: html: color push BlackU color pop html: html:U hanteerdeopgegevenregellengteinplaatsvqandestandaardwaarde80html: html: F*mtiseensimpGelprogrammauithtml: html:BSDhtml: html:Unixomeentekstbestandwatnetteroptemakenmeteenstandaard regellengte,'vqan72(75voGorhtml: html:GNU).BlancoeningesprongenregelsblijvenbGehouden.Hetprogrammahtml: html:prisgemaakt om~tekstinkolommentezettenmetkop-envoGetregelsvoGorhetafdrukken.V*oGorCbcodeiserhtml: html:indent,datdelay-out vqanU eenprogrammahelemaalkanomgoGoien.Desyntaxisluidt:@html: html:html: html: X fmt@html: html:U [-html: html:opties]html: html:[html: html:file...]html: html: DeU oudehtml: html:BSDversiekentgeenopties;dehtml: html:GNUversieheefto.a.:@html: html:html: html:html: html: X -cU (crown-margin)html: html:( color push BlackU color pop html: html:deinspringingvqandeeerstetweeregelsvanelkealineablijftbGewaardenderestspringtevenveelinalsde tweedeU regel;bGedoeldU voorwiealinea'sbegintmetintespringen html: html:html: html: -tU (tagged)html: html:( color push BlackU color pop html: html:U alsdeoptiehtml: html:-c,maardeeerstetweeU regelsmoGetenverschillendU inspringenhtml: html:html: html: -uU (uniform)html: html:( color push BlackU color pop html: html:vervqangtmeervoudigespatiesdoGoreenenkele,bGehalveaanheteindvqaneenregel,waareenenkelespatieblijft staan,U maarmeerderespatiesdoGortweeU wordenvervqangenhtml: html:html: html: -w=html: html:lengte㶺(width)html: html:( color push BlackU color pop html: html:U geeftderegellengteophtml: html:# 3.23.dRinstallhtml: html: Het;commandohtml: html:installcommandowordthetmeestgebruiktinhtml: html:makelesombGestandennaarhunbGestemmingte kopiren.DevergelijkingvqandemanpageslaatziendatdeSystemVenhtml: html:GNUuitvoGeringensterkverschillen.De syntaxisU luidtongeveer:@html: html:html: html: install@html: html:U [-f]html: html:[-mhtml: html:mode]html: html:[-uhtml: html:user]html: html:[-ghtml: html:groep]html: html:html: html:filehtml: html:html: html:directoryhtml: html: EnkeleU vqandeopties:@html: html:0ۺcolor push BlackG50Ff color pop3"Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: -fU (force)html: html:( color push BlackU color pop html: html:U overschrijfeeneventueelbGestaandbestandindedoeldirectory -mU (moGde)html: html: color push BlackU color pop html: html:)detoGegangsrechten)vqandekopiewordeningesteldopdeopgegevenhtml: html:moGde,diezowelalsoGctaalgetalalsin symbGolischeU vormkqanwordenopgegeven(voGormeerinfo:html: html:manchmoGd) html: html:html: html: ( -uU (user)html: html:html: html: -oU (owner)html: html:( color push BlackU color pop html: html:U.steltdeeigenaarvqandekopiein:ditmageennaamofnummeruithtml: html:/etc/passwdzijn;installwordtdoGorgaans doGorU html: html:rootuitgevoerd html: html:html: html: X -gU (groGep)html: html: color push BlackU color pop html: html:U geeftdegroGepopdiedekopiezalbezittenhtml: html:# 3.24.dRlo\#okhtml: html:html: html: LoGokprintalleregelsineengesorteerdtekstbestanddiemetdeopgegevenstringbeginnen.Hetmaaktgebruikvqan eenbinairzoGekqalgorithme,waardoorhetveelsnellerisdanfgrep,maarookbeperkterinzijnfunctionaliteit.De syntaxisU luidt:@html: html:html: html: X loGok@html: html:U [-d]html: html:[-f]html: html:html: html:stringhtml: html:[html: html:file]html: html: T*enzij8eenbGestandisopgegeven,kijktlookinhetstandaardwoordenboek,8bijv.html: html:/usr/dict/wordsofhtml: html:/usr/share/dict/words. EnkeleU optieszijn:@html: html:html: html:html: html: X -dU (dictionary)html: html:( color push BlackU color pop html: html:U houdtlexigraschevolgordeaanenvergelijktenkelletters,cijfersenwitruimte html: html:html: html: -fU (fold)html: html:( color push BlackU color pop html: html:U maaktgeenonderscheidtussenhoGofd-enkleineletterhtml: html:# 3.25.dRmailhtml: html:html: html: Mailishetstandaardinteractievee-mailprogrammavoGorhtml: html:Unixgebruikers.Erzijninmiddelse-mailclientsmet heel!dwatmeerfeatures,maarmailkqangebruiktwordenombGerichtenteversturenvqanuiteenprogramma.Desterk vereenvoudigdeU syntaxisluidt:@html: html:html: html: X mail@html: html:U [-shtml: html:onderwerp]html: html:[html: html:adres...]html: html: Alshetadresontbreekt,danwordtmailgebruiktominteractieftebinnengekomenpGosttelezeneneventueelte wissen; meteenadreszalmaileenbGericht vqandestandaardinvoer lezenenversturenmetdeeventueleonderwerp-0ۺcolor push BlackG51Ff color pop47.Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hjregel(graagtussenaanhalingstekensalserspatiesinvoGorkomen).Alsermeerdereontvqangerszijn,moGetende adressenU metkomma'swordengescheiden.ۺhtml: html:! 3.26.dRmesgShtml: html:html: html: Mesg wordt]meestalinhtml: html:~/.profile(ziecolor push gray 0html:Paragraaf1.3 html: color pop)gebruiktomhetontvqangenvanbGerichten]opdeterminalmet html: html:talkU ofhtml: html:writetoGetestaanofteblokkeren.Desyntaxisluidt:@html: html:html: html: X mesg@html: html:U [html: html:nhtml: html:|y]html: html: Metghtml: html:ywordenbGerichtenaanudoGorgegeven,methtml: html:nniet.Zonderargumentgeeftmesgdemomentaneinstelling.De volgendeU listinglaatziendatervqantweeingelogdegebruikerseenmesgaanheeftstaanendeanderuit. html: html: crw-rw-rw-G1root nroot3,G0Jun n519:29/dev/ttyp0 3 crw--w----G1danieltty n3,1Jun519:26/dev/ttyp1 crw-------G1radicaltty3,2Jun n519:31/dev/ttyp2 crw-rw-rw-G1root%root3,3May1800:44/dev/ttyp3html: html:# 3.27.dRo\#denstringsShtml: html:html: html: OdwordtgebruiktomdeinhoudvqanbinairelesinoGctaalofandereformatenweertegeven.Devereenvoudigde syntaxisU luidt:@html: html:html: html: X oGd@html: html:U [-html: html:[b]html: html:[c]html: html:[d]html: html:[h]html: html:[o]html: html:[x]]html: html:[-Ahtml: html:radix]html: html:[-jhtml: html:bytes]html: html:[-Nhtml: html:bytes]html: html:\html: html: ( [-tU html: html:formaat]html: html:[html: html:file]html: html: ErU zijnonderanderedevolgendeopties:@html: html:html: html:html: html: X -bU (bytes)html: html:( color push BlackU color pop html: html:U byteswordenweergegevenalsoGctaalgetal html: html:html: html: -cU (character)html: html:( color push BlackU color pop html: html:U byteswordenweergegeveninhtml: html:ASCIGI,metonzichtbaretekensalsescapGe(ziecolor push gray 0html:Paragraaf2.2 html: color pop) html: html:html: html: ( -dU (decimal)html: html: color push BlackU color pop html: html:U woGordenvqantweebyteswordenweergegevenalspGositiefdecimaalgetal html: html:html: html: X -xU (hexadecimal)html: html: color push BlackU color pop html: html:U woGordenwordenweergeveninhexadecimalenotatie html: html:html: html: X -vU (verbGose)html: html: color push BlackU color pop html: html:U alseenregelmeerderekerenherhaaldwordt,danwordt-ieoGoknetzovqaakafgedrukt html: html:html: html: X -AU (address)html: html: color push BlackU color pop html: html:U geefhetgetallenstelselopdatvoGordeadressenmoetwordengebruikt0ۺcolor push BlackG52Ff color pop5I*Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html:html: html: -jU (jump)html: html:( color push BlackU color pop html: html:xWgeeftaandateenaantalbytesmoGetwordenovergeslagenalvorensderestaftedrukken;hetaantalwordtin hetU decimalestelselgenoteerd,tenzijhetmeteenhtml: html:0(oGctaal)ofhtml: html:0x(hexadecimaal)begint;html: html: ( achterɿhetaantalkqannogdeeenheidhtml: html:b(blokkenvqan512bytes),html: html:k(1024bytes)ofhtml: html:m(1048576bytes)volgen; oudererversiesvqanoGdzettenditaantalachterdelenaammeteenhtml: html:+ervoGorinoctalenotatieofdecimaalmet eenU puntachterhetgetalhtml: html:html: html: -NU (numbGer)html: html:( color push BlackU color pop html: html:_geefhetaantalbytesaandatvqaniederelemoGetwordenafgedrukt;achterhetaantalkqannogdeeenheidhtml: html:b (blokkenU vqan512bytes),html: html:k(1024bytes)ofhtml: html:m(1048576bytes)volgen html: html:html: html: ( -tU (typGe)html: html:( color push BlackU color pop html: html:(neenalternatievemanieromhetformaataantegeven:hettypGekqanmethtml: html:a,html: html:c,html: html:d,html: html:f,html: html:o,html: html:uofhtml: html:xwordenaangeduid, waarin/Ghtml: html:astaatvoGorhtml: html:ASCII,html: html:fvoorhtml: html:oatingpoint,html: html:dvoGordecimaalenhtml: html:uvoGoreenpositiefdecimaalgetal;achter deU letterkqannogdelengtewordenopgegevenmethtml: html:1,html: html:2,html: html:4ofhtml: html:8byteshtml: html:html: html: StringsiseenruwtoGoltjeomtekstfragmentenuitbinairebGestanden,metnameprogramma's,telteren.Desyntaxis luidt:@html: html:html: html: strings@html: html:U [-html: html:[a]]html: html:[-html: html:[n]html: html:lengte]html: html:[-thtml: html:html: html:dhtml: html:|ohtml: html:|x `]html: html:[le...]html: html: DeU optiesluiden:@html: html:html: html:html: html: X -aU (all)html: html:( color push BlackU color pop html: html:doGorzoekhelebestandinplaatsvqanalleendehtml: html:datasectievaneenprogramma;dezeoptiekanwordenafgekort totU eenenkelmin-teken html: html:html: html: -nU (numbGer)html: html:( color push BlackU color pop html: html:geeftaandatallestringsmetminimumhtml: html:lengteAwordengeretourneerdinplaatsvqandestandaardwaarde4; dezeU optiemagwordenafgekorttothtml: html:-html: html:lengte {html: html:html: html: -tU (typGe)html: html:( color push BlackU color pop html: html:DzorgtervoGordatvoGorelkegevondenstringdepGositieindelewordtafgedruktindecimale,oGctale,ofhex- adecimaleU notatiehtml: html:# 3.28.dRprintenvShtml: html:html: html: PrintenvxdruktU dewaardevqanomgevingsvariabGelenaf.Desyntaxisluidt:@html: html:html: html: X printenv@html: html:U [vqariabGele...]html: html: Zonder8argumentenwordenallevqariabGelenafgedrukt,netalsmethtml: html:set;alsdenamenvanvariabGelenwordenmeegegeven, danU wordendieafgedrukt.html: html:printenvTERMdoGetvrijwelhetzelfdealshtml: html:echo$TERM.0ۺcolor push BlackG53Ff color pop6\Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdhtml: html:fdUnixU shellscriptingFf color pop㖍ۺ^jhtml: html: DeU exitstatusishtml: html:0(true)alsallevqariabGelenbestaanenhtml: html:1(false)alsernongedenieerdis.html: html:! 3.29.dRsleepShtml: html:html: html: SleepU onderbreektdeuitvoGeringvqaneenprogrammatijdelijk.Desyntaxisluidt:@html: html:html: html: X sleep@html: html:U html: html:secondenhtml: html: SleepU wordtvoGoralgebruiktomineenoneindigelusdeprocessornietnodeloostebelastenindetrantvqan@html: html:html: html: whileGtrue 3 donifG[html: html:er_is_postE]nthenhtml: html:lees_postbreaknsleepG10 donehtml: html:# 3.30.dRsuhtml: html: Met[hethtml: html:substituteuserkqaneennieuwe[shellwordenopgestartondereenanderenaam;standaardisdatroGot,ook weloeensalssupGeruseraangeduid.Naeenhtml: html:exitcommandokomtuweerterugindeoudeshell.Suvraagtuiteraard omdhetwachtwoGord,dtenzijhetdoorrootwordtuitgevoGerd.HetwordtoGokvqaakgebruiktomeenprogrammajuist minderU privilegestegevenvoGordeveiligheid.Desyntaxisluidt:@html: html:html: html: X su@html: html:U [-]html: html:[html: html:naam]html: html:[-chtml: html:commando]html: html: Standaard^erftdenieuwe^shelldeoudeomgeving(directoryenvqariabGelen),maardehtml: html:-optiemaakteenhtml: html:loginshellen voGertۭhtml: html:~/.profileuite.d.Metdehtml: html:-coptiewordtinplaatsvqaneeninteractieveshelleenenkelcommandouitgevoGerd. V*ergelijkU eensdevolgendetweeopGdrachten.@html: html:html: html: suG-c"whoami" 3 suG-c"whoami"html: html:# 3.31.dRteehtml: html:html: html: T*ee vormteent-stukineenpijpleiding.HetiseeneenvoudiglterdatdestandaardinvoGerbehalvenaardeuitvoGer oGokU naardeopgegevenleskopieert.ZieoGokcolor push gray 0html:Paragraaf1.7 html: color pop.Desyntaxisluidt:@html: html:html: html: X tee@html: html:U [-a]html: html:[-i]html: html:[html: html:file...]html: html: DeU optiesluiden:@html: html:0ۺcolor push BlackG54Ff color pop7t&Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hj-aU (appGend)ۺhtml: html:( color push BlackU color pop html: html:U plaktdeuitvoGerachterdele(s)inplaatsvqanzeteoverschrijven html: html:html: html: ( -iU (ignore)html: html: color push BlackU color pop html: html:U NegeereeneventueelU html: html:SIGINTsignaalhtml: html:# 3.32.dRtimehtml: html:html: html: Time0kqanzowel0eeninternshellcommandoalsexternprogrammazijn.HetvoGerteenprogrammauitengeeftweer hoGeveeltijdhetgekostheeftalsverstrekentijdenhetaantalsecondendatdecomputereraanheeftbGesteedinde html: html:userU enhtml: html:systemmoGdus.Desyntaxisluidt:@html: html:html: html: X time@html: html:U html: html:commandohtml: html:[html: html:argument...]html: html:# 3.33.dRtrhtml: html:html: html: T*riseeneenvoudiglterwaarmeetekensineentekstbGestanddooranderevervqangenkunnenwordenzonderde krachttofcomplexiteitvqanbijvoGorbeeldtsed;debGewerktestandaardinvoGerverschijntopdestandaarduitvoGer.De SytemU V,html: html:BSDenhtml: html:GNUversieslopGennogaluiteen.Desyntaxisluidtongeveer:@html: html:html: html: X tr@html: html:U [-c]html: html:[-s]html: html:[-d]html: html:html: html:string1html: html:[html: html:string2]html: html: DeU optieszijn:@html: html:html: html:html: html: X (geen)html: html:( color push BlackU color pop html: html:V*ervqangalletekensindeverzamelinghtml: html:string1doGorhetcorresponderendetekeninhtml: html:string2,dieevenlang moGetenU zijn,bijvoorbeeldhtml: html:tr'[:upper:]''[:lower:]'U omallehoofdlettersdoorkleinetevervqangen html: html:html: html: ( -cU (complement)html: html:( color push BlackU color pop html: html:V*ervqangalletekensinhtml: html:string1doGortekensdienietinhtml: html:string1voGorkomen;hetresultaatkqanpGerbestur- ingssysteemU verschillen html: html:html: html: X -dU (delete)html: html:( color push BlackU color pop html: html:U V*erwijderalletekensdievoGorkomeninhtml: html:string1 8Phtml: html:html: html: ǰ -sU (squeeze)html: html: color push BlackU color pop html: html:alseentekenuithtml: html:string1meerderekerenachterelkqaarvoGorkomt,danblijftermaarnoverindeoutput, bijvoGorbeeldU html: html:tr-s'\000-\040'verwijdertdubbGelespaties,legeregelse.d.html: html: De%optieskunnenoGokgecombineerdworden.IndestringsmogendebackslashescapGesvqancolor push gray 0html:Paragraaf2.2 html: color popende kqarakter*klassenvancolor push gray 0html:Paragraaf3.3 html: color popwordengebruikt.T*evenskunnenreeksentekenswordenaangegevenmethtml: html:html: html:begin- eind㶺enU html: html:[html: html:teken*html: html:aantal].8html: html:0ۺcolor push BlackG55Ff color pop8/Оx#jۺcolor push Blackhtml:color push gray 0 color pop html:fdUnixU shellscriptingFf color pop㖍hj3.34.dRwcۺhtml: html:html: html: W*cU iseeneenvoudigU toGoltjeomdelengtevqaneenteksttetellen.Desyntaxisluidt:@html: html:html: html: X wc@html: html:U [-l]html: html:[-w]html: html:[-c]html: html:[html: html:file...]html: html: DeU optieszijn:@html: html:html: html:html: html: -lU (lines)html: html:( color push BlackU color pop html: html:U telhetaantalregels html: html:html: html: -wU (words)html: html:( color push BlackU color pop html: html:U telhetaantalwoGorden html: html:html: html: -cU (characters)html: html: color push BlackU color pop html: html:U telthetaantalhtml: html:bytes;sommigeversieshebbGeneenoptiehtml: html:-mdiekqarakterstelthtml: html: Standaardwordenregels,woGordenenbytesoftekensgeteld.Alsermeerdereleswordenopgegeven,danvolgtnog eenU regelmethettotaaloverU alleles(verwarrendU alsueenbGestandhtml: html:totalhebt:-)html: html:! 3.35.dRyesShtml: html:html: html: Y*esiseensimpGelprogrammaatje,datzolanghtml: html:yofeenanderestringproduceerttotdathetwordtafgebroken.De syntaxisU luidt:@html: html:html: html: X yes@html: html:U [html: html:string]html: html: HettwordtvoGoralgebruiktinpijpleidingen,zoalshtml: html:yesn|fsck/F*sckzalvragenofuwelzekerweetdatuhetroGot lesysteemwiltcontroleren;omdatdatriskqantisopeenaktiefsysteemwordtdievraagautomatischmethtml: html:n(ee) bGeantwoord.0ۺcolor push BlackG56Ff color pop;8H 8/J aeitt10.xtcrm0800,. ecrm09007Lecrm0600J aeitt10J aett10J aeitt10ck aett99 tcrm1000DM% aessbx10DM%ff aessbx10DM%G aessbx10DM% aessbx10 1 ecrm1000 !", cmsy10v