5 WIP
This commit is contained in:
0
beispiele/mysystem.sh → beispiele/4/mysystem.sh
Normal file → Executable file
0
beispiele/mysystem.sh → beispiele/4/mysystem.sh
Normal file → Executable file
17
beispiele/4/rename-jpg.sh
Normal file
17
beispiele/4/rename-jpg.sh
Normal 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
8
beispiele/5/01-vars.sh
Normal 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"
|
10
beispiele/5/02-comments.sh
Normal file
10
beispiele/5/02-comments.sh
Normal 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.
|
28
beispiele/5/recursive-func.sh
Normal file
28
beispiele/5/recursive-func.sh
Normal 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
27
beispiele/5/while-menu.sh
Normal 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
|
Reference in New Issue
Block a user