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

2
4.html
View File

@ -219,7 +219,7 @@ USER Benutzername</code></pre>
</section> </section>
<section style="font-size: .6em"> <section style="font-size: .7em">
<pre><code>#!/bin/bash <pre><code>#!/bin/bash
clear clear
echo "Diese Infos werden von mysystem.sh bereitgestellt." echo "Diese Infos werden von mysystem.sh bereitgestellt."

120
5.html
View File

@ -40,7 +40,7 @@
<section data-transition="slide" data-background="#4d7e65" data-background-transition="zoom"> <section data-transition="slide" data-background="#4d7e65" data-background-transition="zoom">
<h1>LINUX</h1> <h1>LINUX</h1>
<h3>Das universelle Betriebssystem</h3> <h3>Das universelle Betriebssystem</h3>
<p>Eine Einführung - Teil 4 <p>Eine Einführung - Teil 5
<p> <p>
<small>Deutsche Angestellten Akademie</small> <small>Deutsche Angestellten Akademie</small>
</p> </p>
@ -51,24 +51,118 @@
</section> </section>
<section> <section>
<h2>vim und emacs</h2> <h2>Bash scripting - Fortsetzung</h2>
<h3>Die mächtigen Unix Editoren</h3>
</section> </section>
<section data-transition="slide" data-background="#4d7e65" data-background-transition="zoom"> <section>
<h3>vim</h3> <h3>LINKS</h3>
<p>http://tldp.org/LDP/abs/html/complexfunct.html
<p>http://programmingexamples.wikidot.com/bash-scripting#toc24
<p>https://wiki.ubuntuusers.de/Shell/Bash-Skripting-Guide_für_Anfänger/#Quoting
<div>
- script kontrolle ( strg-z etc )
- input
- parameter
- functions
- kontrollstrukturen
-
</section>
<section>
<h3>Variablen</h3>
<pre><code>#!/bin/bash
x=10 #NICHT x = 10 -> keine Leerzeichen!
X=20 #variablen sind Case Sensitive
$y= #NULL variable
echo "x = $x"
echo "X = $X"
echo "y = $y"</code></pre>
</section>
<section>
<h3>Kommentare</h3>
<pre><code>
#!/bin/bash
# Diese Zeile ist ein Kommentar
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.
</code>
</pre>
</section>
<section>
<h3>Quotes</h3>
<ul> <ul>
<li class="fragment">ein Editor für die shell </li> <li class="fragment ">Double Quotes: " " -Anything enclose in double quotes removed meaning of that characters (except \ and $).</li>
<li class="fragment">immer da, oft in der alten Variante „vi“ </li> <li class="fragment ">Single quotes: ' ' - Enclosed in single quotes remains unchanged.</li>
<li class="fragment">Vi IMproved</li> <li class="fragment ">Back quote: ` ` - To execute command</li>
<li class="fragment">komplett per Kürzel steuerbar </li>
<li class="fragment">umfassend anpassbar </li>
<li class="fragment">erweiterbar </li>
<li class="fragment">syntax highlighting </li>
<li class="fragment">vim ist einfach cool ;-)</li>
</ul> </ul>
</section>
<section>
<h3>Input - Output redirection</h3>
<ul>
<li class="fragment "> > : output in Datei. Best. Datei wird überschrieben!</li>
<li class="fragment "> >> : output an Datei anhängen.</li>
<li class="fragment "> < : Kommando Input aus Datei lesen</li>
</ul>
<pre><code>#!/bin/bash
echo "ls > file_list"
ls > file_list
echo "ls -la >> file_list"
ls -la >> file_list
echo "cat < file_list"
cat < file_list</code></pre>
</section> </section>
<section>
- arithmetik
let "m = 4 * 1024";echo $m
let "m += 15"
let "m -= 3"
let "m /= 5"
let "m %= 10"
let "m++"
let "m--"
let "k = (m < 9) ? 0 : 1"
condition ? value-if-true : value-if-false
Floating Poin:
echo "32.0 + 1.4" | bc
echo `expr $m + 18`
m=`expr $m + 18`
(( m *= 4 ))
</section>
<section data-transition="slide" data-background="#4d7e65" data-background-transition="zoom">
</section>
<section> <section>
<h3>Die 5 Level eines Vim Magiers</h3> <h3>Die 5 Level eines Vim Magiers</h3>

0
beispiele/mysystem.sh → beispiele/4/mysystem.sh Normal file → Executable file
View File

17
beispiele/4/rename-jpg.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
suf=$1
if [ $# -gt 0 ]
then
for f in *.$suf; do
bn=`basename "$f" .$suf | sed 's/IMG_//'`
new=$bn.$suf
echo "neuer Dateiname:"
echo $new
mv "$f" $new
done
else
echo "Kein Suffix gegeben!!"
echo "Verwendung: strip-space.sh SUFFIX"
echo "Beende ...."
exit 1
fi

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

View File

@ -1,19 +0,0 @@
wiederholugn
regexp
bash config
scripting
cp `find . -name "*.jpg"` neuer_ordner
for FILE in *.JPG
do
NEWFILE2=`echo "$FILE" | sed 's/.(*)/\-/'`
echo "$NEWFILE2"
mv "$FILE" "$NEWFILE2"
done