Linux
HOGENT toegepaste informatica
2026-2027
Informatie uitwisselen tussen script en omgeving:
stdin, stdout,
stderr$1, $2, enz.Een functie gedraagt zich als een commando!
functie_naam arg1 arg2 arg3${1}, ${2},
enz.return STATUS ipv exitHoe kan je een functie een “waarde” laten teruggeven? Via
stdout!
stdout van command wordt opgevangen en
opgeslagen in variabele ${output}.
Wat is de uitvoer van dit script?
Wat is de uitvoer van dit script?
# Usage: copy_iso_to_usb ISO_FILE DEVICE
# Copy an ISO file to a USB device, showing progress with pv (pipe viewer)
# e.g. copy_iso_to_usb FedoraWorkstation.iso /dev/sdc
copy_iso_to_usb() {
local iso="${1}"
local destination="${2}"
local iso_size
iso_size=$(stat -c '%s' "${iso}")
printf "Copying %s (%'dB) to %s\n" \
"${iso}" "${iso_size}" "${destination}"
dd if="${iso}" \
| pv --size "${iso_size}" \
| sudo dd of="${destination}"
}Zie Parameter Substitution in de Advanced Bash-Scripting Guide.
Verwijder patroon van begin/einde van een string:
PATROON in globbing syntax!
(man 7 glob)
\ op het einde van
een regel)