From ff7035cd22c342243e00d805565bc1b38faa617e Mon Sep 17 00:00:00 2001 From: Olli Graf Date: Mon, 15 Sep 2025 09:37:35 +0200 Subject: [PATCH] =?UTF-8?q?power.sh=20f=C3=BCr=20mehrdimensionale=20Arrays?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arrays/.gitignore | 2 ++ arrays/access.sh | 1 + arrays/create.sh | 12 +----------- arrays/declare.sh | 1 + arrays/iterate.sh | 2 ++ arrays/length.sh | 1 + arrays/power.sh | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 arrays/.gitignore create mode 100755 arrays/power.sh diff --git a/arrays/.gitignore b/arrays/.gitignore new file mode 100644 index 0000000..b05de43 --- /dev/null +++ b/arrays/.gitignore @@ -0,0 +1,2 @@ +*.bak + diff --git a/arrays/access.sh b/arrays/access.sh index 098c84f..4be343b 100755 --- a/arrays/access.sh +++ b/arrays/access.sh @@ -1,4 +1,5 @@ #! /usr/bin/bash +# File: access.sh # Array of numbers fib=(0 1 2 3 5 8) diff --git a/arrays/create.sh b/arrays/create.sh index cce0f07..cf97cbb 100755 --- a/arrays/create.sh +++ b/arrays/create.sh @@ -1,4 +1,5 @@ #! /usr/bin/bash +# File: create.sh a1=(0 1 2 3 4) family=("Marge" "Homer" "Bart" "Lisa" "Maggie") @@ -7,14 +8,3 @@ echo "a1=${a1[@]}" echo "family=${family[@]}" echo "Länge family: ${#family[@]}" -# Define an Array with declare -a -declare -a sbc -sbc[0]="Raspberry Pi" -echo "Länge sbc: ${#sbc[@]}" -echo "sbc=${sbc[@]}" -sbc[1]="Orange Pi" -echo "Länge sbc: ${#sbc[@]}" -echo "sbc=${sbc[@]}" -sbc[2]="Banana Pi" -echo "Länge sbc: ${#sbc[@]}" -echo "sbc=${sbc[@]}" diff --git a/arrays/declare.sh b/arrays/declare.sh index 2fe4144..f777ff0 100755 --- a/arrays/declare.sh +++ b/arrays/declare.sh @@ -1,4 +1,5 @@ #! /usr/bin/bash +# File: declare.sh declare -a sbc sbc[0]="Raspberry Pi" diff --git a/arrays/iterate.sh b/arrays/iterate.sh index 82ea38b..ba9f118 100755 --- a/arrays/iterate.sh +++ b/arrays/iterate.sh @@ -1,4 +1,5 @@ #! /usr/bin/bash +# File: iterate.sh # Array of numbers fib=(0 1 2 3 5 8) @@ -13,6 +14,7 @@ for name in "${family[@]}" echo "for: name=${name}" done echo "---" + # C-ähnliche Schleife im Index len=${#family[@]} diff --git a/arrays/length.sh b/arrays/length.sh index 491df5b..e3610db 100755 --- a/arrays/length.sh +++ b/arrays/length.sh @@ -1,4 +1,5 @@ #! /usr/bin/bash +# File: length.sh a1=(0 1 2 3 4 5) family=("Marge" "Homer" "Bart" "Lisa" "Maggie") diff --git a/arrays/power.sh b/arrays/power.sh new file mode 100755 index 0000000..2a48438 --- /dev/null +++ b/arrays/power.sh @@ -0,0 +1,38 @@ +#! /usr/bin/bash +# Datei: power.sh + +declare -A power + +# 1. Zeile (Orange Pi Zero 2W), x-Index: 0 + +power[0,0]="Orange Pi Zero 2W" +power[0,1]="1,014" +power[0,2]="1,99" + +# 2. Zeile (Banana Pi BPI-F3) x-Index: 1 +power[1,0]="Banana Pi BPI-F3" +power[1,1]="3,6" +power[1,2]="6,8" + +# 3. Zeile (Raspberry Pi 16GB), x-Index: 2 +power[2,0]="Raspberry Pi 16GB" +power[2,1]="2,25" +power[2,2]="8,0" + +# 4. Zeile (Radxa Zero), x-Index: 3 +power[3,0]="Radxa Zero" +power[3,1]="-" +power[3,2]="-" +# 2. Spalte: Stromaufnahme Leerlauf + +# 3. Spalte: Stromaufnahme unter Last +power[2,3]="" + +printf "%-25s %-10s %-10s\n" "SBC" "idle" "load" + +#printf 'SBC\tload\tidle\n'; +for ((x=0; x<4; x++)) +do + printf "%-20s %-10s %-10s\n" "${power[${x},0]}" "${power[${x},1]}W" "${power[${x},2]}W" +done +