diff --git a/4.html b/4.html index 60d9188..fa06384 100644 --- a/4.html +++ b/4.html @@ -29,6 +29,10 @@ document.getElementsByTagName( 'head' )[0].appendChild( link ); + + @@ -196,6 +200,24 @@ USER Benutzername +
+ Damit ein Script wie ein Programm startet: + + + +
+ +
+

Gentlemen, open your Editor!

+
+
#!/bin/bash
@@ -218,8 +240,8 @@ uptime
 
 MSG="\nDas ist alles! Bye, $USER! \n\n"
 printf "${MSG}"
- - https://git.scytec.de/danthefan/linuxkurs/raw/master/beispiele/mysystem.sh +

https://www.schubertdaniel.de/linuxkurs +

https://git.scytec.de/danthefan/linuxkurs/raw/master/beispiele/mysystem.sh

@@ -280,20 +302,81 @@ dany 23893 4143 0 12:33 pts/4 00:00:00 bash

Der Kontext aller Script Variablen ist der der sub-shell

-
- Damit Script wie Programm startet: - + - + +
+
Aufgabe: Erstellt ein script, das alle Dateien in eurem home in einer tar.gz - Datei archiviert, das Verzeichnis "~/archiv" erstellt, und die tar.gz Datei dorthin verschiebt.
+ Hinweis: tar -czf ..... +

https://linuxconfig.org/bash-scripting-tutorial

+ +
#!/bin/bash
+tar -czf myhome_directory.tar.gz /home/$USER
+mkdir archiv
+mv myhome_directory.tar.gz archiv/
+
+
+ + + +
+
+

Kontrollstrukturen

+
+
+

if then

+ +
+
#!/bin/bash
+cd 
+ls
+if [ -e sample.sh ] 
+then 
+ echo "file exists!" 
+else 
+ echo "file does not exist" 
+fi
+ + +
+

if then elif

+ +
+
#!/bin/bash
+ cd
+ls -l 
+read -p "Enter a file name: " filename
+if [ -e $filename ] 
+then 
+ echo "file exists!" 
+ if [ -r $filename ]
+ then 
+      status="readable " 
+ fi 
+ if [ -w $filename ] 
+ then 
+      status=$status"writable " 
+ fi 
+ if [ -x $filename ] 
+ then 
+      status=$status"executable" 
+ fi 
+  echo "file permission: "$status 
+else 
+ echo "file does not exist" 
+fi
+
+

for loop

+ +
+
#!/bin/bash
+for f in {1..9}
+do
+	touch "$f xx.txt"
+done
+
Ein weiteres Beispiel:
#!/bin/bash
@@ -312,15 +395,66 @@ if [ $# -gt 0 ]
     echo "Beende ...."
 fi
 
+
-
-

Kommando Verkettung

- - +

case

+
+
#!/bin/bash 
+ clear 
+ read -p "Integer1: " int1 
+ read -p "Integer2: " int2 
+ printf "Menu: \n[a] Addition\n[b]Subtraction\n[c]Multiplication\n[d]Division\n" 
+ echo "======================" 
+ read -p "Your choice: " choice 
+ res=0 
+ case $choice in 
+	 a) 
+	     res=$((int1+int2)) 
+	 ;; 
+	 b) 
+	     res=$((int1-int2)) 
+	 ;; 
+	 c) 
+	     res=$((int1*int2)) 
+	 ;; 
+	 d) 
+	     res=$((int1/int2)) 
+	 ;; 
+	 *) 
+	     echo "Invalid input" 
+ esac 
+ echo "The result is: " $res
+
+

while loop

+ +
+
#!/bin/bash
+x=1
+while [ $x -le 5 ]
+do
+  echo "Welcome $x times"
+  x=$(( $x + 1 ))
+done
+
+

until loop

+ +
+
#!/bin/bash
+i=1
+until [ $i -gt 6 ]
+do
+	echo "Welcome $i times."
+	i=$(( i+1 ))
+done
+

while vs until

+
    +
  1. until läuft bis Bedingung nicht 0 (false)
  2. +
  3. while läuft bis Bedingung 0 (true)
  4. +
  5. until läuft mind. einmal
  6. +
+
diff --git a/6.html b/6.html new file mode 100644 index 0000000..d004954 --- /dev/null +++ b/6.html @@ -0,0 +1,117 @@ + + + + + Einführung in Linux + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+

LINUX

+

Das universelle Betriebssystem

+

Eine Einführung - Teil 6 +

+ Deutsche Angestellten Akademie +

+ + +
+ +
+

vim und emacs

+

Die mächtigen Unix Editoren

+
+ +
+

vim

+
    +
  • ein Editor für die shell
  • +
  • immer da, oft in der alten Variante „vi“
  • +
  • Vi IMproved
  • +
  • komplett per Kürzel steuerbar
  • +
  • umfassend anpassbar
  • +
  • erweiterbar
  • +
  • syntax highlighting
  • +
  • vim ist einfach cool ;-)
  • +
+ +
+ +
+

Die 5 Level eines Vim Magiers

+
    +
  • Level 0: nichts über vim wissen +
  • Level 1: vim basics kennen +
  • Level 2: den visual mode kennen +
  • Level 3: diverse „motions“ kennen +
  • Level 4: den visual mode nicht brauchen +
+

https://danielmiessler.com/study/vim/ +

+
+ +
+ + + + + + + + diff --git a/beispiele/remove-spaces.sh b/beispiele/remove-spaces.sh old mode 100644 new mode 100755 index 1af354c..abb6f9c --- a/beispiele/remove-spaces.sh +++ b/beispiele/remove-spaces.sh @@ -13,4 +13,5 @@ if [ $# -gt 0 ] echo "Kein Suffix gegeben!!" echo "Verwendung: strip-space.sh SUFFIX" echo "Beende ...." + exit 1 fi diff --git a/img/2_if_then_elif_fi.svg b/img/2_if_then_elif_fi.svg new file mode 100644 index 0000000..286e583 --- /dev/null +++ b/img/2_if_then_elif_fi.svg @@ -0,0 +1,431 @@ + + + + + + + + image/svg+xml + + + + + + + + + If...condition + + elif...condition + + + true + false + + + + + then + command 1 + command 2... + commandN + + + + true + false + + + + + + else + command 1 + command 2... + commandN + + + + + + + then + command 1 + command 2... + commandN + + fi + diff --git a/img/3_case_var.jpg b/img/3_case_var.jpg new file mode 100644 index 0000000..195cf5b Binary files /dev/null and b/img/3_case_var.jpg differ diff --git a/img/4_while.svg b/img/4_while.svg new file mode 100644 index 0000000..2b27aa2 --- /dev/null +++ b/img/4_while.svg @@ -0,0 +1,662 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + i=1 + + + + While [ $i < 10 ] + + docommandcommandcommandN (($i++)) + + + done + + + Solange Bedingung erfüllt ist,liefert der Rückgabewert 0,Schleifenkommandos werden weiterhin ausgeführt. + Bedingung nicht mehr erfüllt,Rückgabewert 1, Schleife wird beendet. + + + + + While loop + + Variable außerhalb (!) der While-Schleife initialisieren + + Bedingung setzen + Schleifenbefehle werdenausgeführt, solange Bedingungwahr und der Rückgabewert 0 ist. + Variable hochzählen,Bedingung wird neu geprüft. + Entweder neuer Schleifendurchlaufoder Abbruch der Schleife. + 1. + 2. + 3. + 4. + 5. + + + + + + + + + + + + diff --git a/img/for.svg b/img/for.svg new file mode 100644 index 0000000..361f190 --- /dev/null +++ b/img/for.svg @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + for...loop + + .. + string 7 + string 1 + string 2 + string 3 + string 4 + string 5 + string 6 + liste + + + + for var in liste + + + docommandcommand...commandN + + + + done + + + + + diff --git a/img/if_then_else.svg b/img/if_then_else.svg new file mode 100644 index 0000000..a9aff27 --- /dev/null +++ b/img/if_then_else.svg @@ -0,0 +1,582 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + If ...then...fi statement + + + + + + If...condition + If...then...else...fi statement + + + + + + + + ... + + then + command 1 + command 2 + commandN + + + fi + + + + then + command 1 + command 2 + commandN + + + + If...condition + + then + command 1 + command 2 + commandN + + + + then + command 1 + command 2 + commandN + + fi + + + + + + + + else + command 1 + command 2 + commandN + + diff --git a/img/until.svg b/img/until.svg new file mode 100644 index 0000000..0c02400 --- /dev/null +++ b/img/until.svg @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + Solange Bedingungnicht erfüllt ist, liefertder Rückgabewert 1,Schleifenkommandos werden weiterhin ausgeführt. + + + + + until... loop + + Bedingung erfüllt,Rückgabewert 0, Schleife wird beendet. + + until [condition] + + + docommandcommand...commandN + + + + + + + done + + + diff --git a/index.html b/index.html index c03e9bc..14e1cac 100644 --- a/index.html +++ b/index.html @@ -37,10 +37,16 @@