Browse Source

Scripts zu Rückgabewerte.

master
Olli Graf 2 months ago
parent
commit
23e7a9090a
  1. 3
      teil16/loop-func.sh
  2. 9
      teil16/mult-echo.sh
  3. 1
      teil16/param-func.sh
  4. 14
      teil16/return-value-echo.sh
  5. 20
      teil16/return-value-echo2.sh
  6. 18
      teil16/return-value-return.sh
  7. 5
      teil16/simple-func.sh

3
teil16/loop-func.sh

@ -1,8 +1,9 @@
#! /usr/bin/bash #! /usr/bin/bash
# File: loop-func.sh
function hallo() { function hallo() {
echo "Hallo 1" echo "Hallo 1"
echo "Hallo 2" echo "-------"
} }
count=1 count=1

9
teil16/mult-echo.sh

@ -1,13 +1,14 @@
#! /usr/bin/bash #! /usr/bin/bash
# File: mult-echo.sh
echo "Hallo 1" echo "Hallo 1"
echo "Hallo 2" echo "-------"
echo "Hallo 1" echo "Hallo 1"
echo "Hallo 2" echo "-------"
echo "Hallo 1" echo "Hallo 1"
echo "Hallo 2" echo "-------"
echo "Hallo 1" echo "Hallo 1"
echo "Hallo 2" echo "-------"

1
teil16/param-func.sh

@ -1,4 +1,5 @@
#! /usr/bin/bash #! /usr/bin/bash
# File: param-func.sh
function hallo() { function hallo() {
echo "Hallo ${1}" echo "Hallo ${1}"

14
teil16/return-value-echo.sh

@ -0,0 +1,14 @@
#! /usr/bin/bash
# File: return-value-echo.sh
function square() {
echo $(( ${1} * ${1} ))
}
square "2"
square "4"
square "3"
square "32"

20
teil16/return-value-echo2.sh

@ -0,0 +1,20 @@
#! /usr/bin/bash
# File: return-value-echo2.sh
function square() {
echo $(( ${1} * ${1} ))
}
s2=$(square "2")
s4=$(square "4")
s3=$(square "3")
s32=$(square "32")
echo "Das Quadrat von 2 ist ${s2}"
echo "Das Quadrat von 4 ist ${s4}"
echo "Das Quadrat von 3 ist ${s3}"
echo "Das Quadrat von 32 ist ${s32}"

18
teil16/return-value-return.sh

@ -0,0 +1,18 @@
#! /usr/bin/bash
# File: return-value-return.sh
function square() {
return $(( ${1} * ${1} ))
}
square "2"
echo "Quadrat von 2 ist ${?}"
square "4"
echo "Quadrat von 4 ist ${?}"
square "3"
echo "Quadrat von 3 ist ${?}"
square "32"
echo "Quadrat von 32 ist ${?}"

5
teil16/simple-func.sh

@ -1,12 +1,13 @@
#! /usr/bin/bash #! /usr/bin/bash
# File: simple-func.sh
function hallo() { function hallo() {
echo "Hallo 1" echo "Hallo 1"
echo "Hallo 2" echo "-------"
} }
hallo hallo
hallo hallo
hallo hallo
hallo hallo

Loading…
Cancel
Save