This commit is contained in:
2019-01-08 13:08:27 +01:00
parent ea67258714
commit 87205c16f0
14 changed files with 201 additions and 36 deletions

8
beispiele/5/01-vars.sh Normal file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
x=10 #NOT x = 10 no spaces
X=20 #variables are case sensitive
$y= #NULL variable
echo "x = $x"
echo "X = $X"
echo "y = $y"

View File

@@ -0,0 +1,10 @@
#!/bin/bash
# This line is a comment.
echo "A comment will follow." # Comment here.
echo "The # here does not begin a comment."
echo 'The # here does not begin a comment.'
echo The \# here does not begin a comment.
echo The # here begins a comment.
echo ${PATH#*:} # Parameter substitution, not a comment.
echo $(( 2#101011 )) # Base conversion, not a comment.

View File

@@ -0,0 +1,28 @@
#!/bin/bash
# Beispiel für Rekursive Funktion
#Funktions-Definition
function sum() {
if [ -z "$2" ]; then
#Rückgabewert
echo $1
else
a=$1;
#Parameter werden nach links verschoben : orkus <- $1 , $1 <- $2
shift;
#Funktion ruft sich selbst auf - Rekursion
#Ergebnis. b == 2
b=`sum $@`
echo `expr $a + $b` # <- 1 + 2
fi
}
# Funktions-Aufruf mit 2 Parametern
sum 1 2

27
beispiele/5/while-menu.sh Normal file
View File

@@ -0,0 +1,27 @@
# Script to create simple menus and take action according to that selected
# menu item
#
while :
do
clear
echo "-------------------------------------"
echo " Main Menu "
echo "-------------------------------------"
echo "[1] Show Todays date/time"
echo "[2] Show files in current directory"
echo "[3] Show calendar"
echo "[4] Start editor to write letters"
echo "[5] Exit/Stop"
echo "======================="
echo -n "Enter your menu choice [1-5]: "
read yourch
case $yourch in
1) echo "Today is `date` , press a key. . ." ; read ;;
2) echo "Files in `pwd`" ; ls -l ; echo "Press a key. . ." ; read ;;
3) cal ; echo "Press a key. . ." ; read ;;
4) vi ;;
5) exit 0 ;;
*) echo "Opps!!! Please select choice 1,2,3,4, or 5";
echo "Press a key. . ." ; read ;;
esac
done