Skip to content

Shell-scripting Spiekbriefje

Shell-scripting Spiekbriefje

Variabelen

Opdracht Uitleg
VAR=waarde Variabele definiëren
$VAR Variabele aanroepen
`opdracht` Opdrachtsubstitutie

Flow Control

Opdracht Uitleg
if Voorwaardelijke test
then Uitvoeren als de voorwaarde waar is
else Uitvoeren als de voorwaarde onwaar is
elif Andere voorwaarden
fi Einde voorwaardelijke test
for Lus
while Lus zolang de voorwaarde waar is
do Lus-inhoud
done Einde lus

Functies

Opdracht Uitleg
function_name() {} Functie definiëren
return Terugkeren uit functie
$? Retourwaarde van de laatste opdracht

Scriptbeheer

Opdracht Uitleg
#!/bin/bash Specificeer de interpreter die het script gebruikt
chmod +x script.sh Geef het script uitvoeringsrechten
./script.sh Voer het script uit