Shell Scripting
(zie ook commandolijn algemeen)
Scripting
$0 variabele: bestandsnaam bv: mijnscript.sh
$ variabelen 1-9 parameters # commentaar ${ } var scheiden van txt $# aantal parameters in script pauseren, wachten Quoting:” ‘ ` ‘ ‘ tekst letterlijk exit 0 foutwaarde, 0=ok Let ook: als root: .inputrc in homedir Root: |
Voorbeelden
Keuze in script: echo "Do you wish to install this program?" select yn in "Yes" "No"; do case $yn in Yes ) make install; break;; No ) exit;; esac done Check of uitgevoerd door root:
ZypperRefUp.sh
Install a gambas app after downloading it: #/bin/bash # working on 07/10/2022 # install gambasapp.tar.gz from downloads directory echo " instfromdownload myGb3App (no extention) to install myGb3App.tar.gz from ~/downloads" if [ $# -eq 0 ]; then echo "- No arguments provided; choose from: " ls -lFAh ~/Downloads/*.tar.gz echo "or download (manually if no fixed link) from shared nextcloud folder sharekantoor/swupdates/release or other source" exit 1 fi cd ~/Downloads/ ls -lFAh $1* myapp = $1.tar.gz echo "move and unpack $myapp" cp myapp ~/.systemPrograms/gb3Project/ cd ~/.systemPrograms/gb3Project tar -xzvf myapp echo "compile install $myapp" cd myapp gb3c -a gba3 -o ./../gb3Run/$myapp.gambas echo "cleanup .. " mv ~/.systemPrograms/gb3Source/$myapp /.systemPrograms/gb3Source/previous/ mv /.systemPrograms/gb3Project/$myapp /.systemPrograms/gb3Source/ ls -lFAh /.systemPrograms/gb3Source/$myapp ls -lFAh /.systemPrograms/gb3Source/$myapp rm ~/Downloads/$myapp ls ~/Downloads/$myapp echo "End install, ready to run $myapp" |