Skip to content

Commit efb8409

Browse files
author
R
committed
Adding data to the repository.
1 parent e083df9 commit efb8409

8 files changed

+326
-0
lines changed

Zufallszahl.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#! /bin/bash
2+
3+
# Gibt Zufallszahl aus
4+
5+
$ZZAHL = $(($RANDOM % 10))
6+
echo $ZZAHL

anz_args.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#! /bin/bash
2+
3+
# Gibt die Zahl seiner Argumente aus
4+
echo $#
5+

dov.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#! /bin/bash
2+
3+
#Erstellt Verzeichnis, falls Name noch nicht existiert.
4+
if [ $# == 2 ]; then
5+
case $2 in
6+
"v")
7+
echo "Number of arguments matched. Creating file ..."
8+
if [ -e $1 ]; then
9+
echo "Cannot create directory. Directory- or filename already exists."
10+
else
11+
mkdir $1
12+
echo "Directory successfully created. Thanks for using dov.sh."
13+
fi
14+
;;
15+
"d")
16+
echo "Number of arguments matched. Creating file ..."
17+
if [ -e $1 ]; then
18+
echo "Cannot create file. File- or directoryname already exists."
19+
else
20+
touch $1
21+
echo "File successfully created. Thanks for using file.sh."
22+
fi
23+
;;
24+
*)
25+
echo "Only the creation of directory (v) or file (d) is supported. Please choose one of those arguments."
26+
;;
27+
esac
28+
else
29+
echo "Invalid number of arguments. Not more or less than two arguments supported."
30+
fi

file.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#! /bin/bash
2+
3+
#Erstellt Verzeichnis oder Datei, falls Name noch nicht existiert.
4+
if (($# == 2))
5+
then
6+
if [ $2 == d || $2 == v ]; then
7+
8+
echo "Number of arguments matched. Creating file ..."
9+
if [ -e $1 ]; then
10+
echo "Cannot create file. File already exists."
11+
else
12+
touch $1
13+
echo "File successfully created. Thanks for using file.sh."
14+
fi
15+
else
16+
echo "Illegal number of arguments."
17+
fi
18+

namespaces.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
if [ $# -ne 3 ]
4+
then
5+
echo "All Params are required!"
6+
echo " Usage: $0 PARAM1 PARAM2 PARAM3"
7+
exit 1
8+
fi
9+
10+
echo_params()
11+
{
12+
let count=1
13+
for param in $*
14+
do
15+
echo '$'$count ':' $param
16+
count=$((count + 1))
17+
done
18+
}
19+
20+
inner_function()
21+
{
22+
echo "inner function"
23+
echo_params $*
24+
echo
25+
}
26+
27+
outer_function()
28+
{
29+
echo "outer function"
30+
echo_params $*
31+
echo
32+
inner_function $3 $1
33+
}
34+
35+
echo "script"
36+
echo_params $*
37+
echo
38+
39+
outer_function $3 $2 $1

par.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#! /bin/bash
2+
3+
#Erstellt Verzeichnis, falls Name noch nicht existiert.
4+
if (($# == 1))
5+
then
6+
echo "Number of arguments matched. Creating file ..."
7+
if [ -e $1 ]; then
8+
echo "Cannot create file. File already exists."
9+
else
10+
touch $1
11+
echo "File successfully created. Thanks for using file.sh."
12+
fi
13+
else
14+
echo "Illegal number of arguments."
15+
fi
16+

rentAHero.sh

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#! /bin/bash
2+
3+
# This Program creates a hero
4+
select Hero in Name Strength Dexterity Intelligence Finish
5+
do
6+
case $Hero in
7+
Name)
8+
echo "Please insert the name of your hero."
9+
read hname
10+
if [ ! -e heroes ]; then
11+
mkdir heroes
12+
cd heroes
13+
echo $hname > "${hname}.txt"
14+
echo "Level 1" >> "${hname}.txt"
15+
echo "Your hero will be Level 1 and henceforth be called ${hname}."
16+
else
17+
cd heroes
18+
echo $hname > "${hname}.txt"
19+
echo "Level 1" >> "${hname}.txt"
20+
echo "Your hero will be Level 1 and henceforth be called ${hname}."
21+
fi
22+
;;
23+
Strength)
24+
for (( c=0; c <= 4; c++ ))
25+
do
26+
echo "Rolling dice ... "
27+
sleep 1
28+
StrValue=$(($RANDOM%10-0))
29+
echo "Your Strength value is $StrValue ."
30+
let c++
31+
echo "Re-Roll your Strength [y/n]?"
32+
read q
33+
if [[ $q == "n" ]]; then
34+
let c=4
35+
fi
36+
done
37+
echo "Your heros Strength value of $StrValue was be saved."
38+
echo "Strength: ${StrValue}" >> Values.txt
39+
;;
40+
Dexterity)
41+
for (( c=0; c <= 4; c++ ))
42+
do
43+
echo "Rolling dice ... "
44+
sleep 1
45+
DexValue=$(($RANDOM%10-0))
46+
echo "Your Dexterity value is $DexValue ."
47+
let c++
48+
echo "Re-Roll your Dexterity [y/n]?"
49+
read q
50+
if [[ $q == "n" ]]; then
51+
let c=4
52+
fi
53+
done
54+
echo "Your heros Dexterity value of $DexValue was be saved."
55+
echo "Dexterity: ${DexValue}" >> Values.txt
56+
;;
57+
Intelligence)
58+
for (( c=0; c <= 4; c++ ))
59+
do
60+
echo "Rolling dice ... "
61+
sleep 1
62+
IntValue=$(($RANDOM%10-0))
63+
echo "Your Intelligence value is $IntValue ."
64+
let c++
65+
echo "Re-Roll your Intelligence [y/n]?"
66+
read q
67+
if [[ $q == "n" ]]; then
68+
let c=4
69+
fi
70+
done
71+
echo "Your heros Intelligence value of $IntValue was be saved."
72+
echo "Intelligence: ${IntValue}" >> Values.txt
73+
74+
;;
75+
Finish)
76+
if [ ! -e heroes ]; then
77+
mkdir heroes
78+
cd heroes
79+
else
80+
if [ -e "${hname}.txt" ]; then
81+
cat Values.txt >> "${hname}.txt"
82+
echo "Your hero has the following attributes: "
83+
cat "${hname}.txt"
84+
sleep 4
85+
echo "Your hero was saved to ${hname}.txt"
86+
rm Values.txt
87+
cd ..
88+
break
89+
else
90+
echo "Your hero still needs a name. Please insert one now."
91+
read hname
92+
echo $hname > "${hname}.txt"
93+
echo "Level 1" >> "${hname}.txt"
94+
cat Values.txt >> "${hname}.txt"
95+
echo "Your hero has the following attributes: "
96+
cat "${hname}.txt"
97+
sleep 4
98+
echo "Your hero was saved to ${hname}.txt."
99+
rm Values.txt
100+
cd ..
101+
break
102+
fi
103+
fi
104+
;;
105+
esac
106+
done

rentAHero_Save.sh

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#! /bin/bash
2+
3+
# This Program creates a hero
4+
select Hero in Name Strength Dexterity Intelligence Finish
5+
do
6+
case $Hero in
7+
Name)
8+
echo "Please insert the name of your hero."
9+
read hname
10+
if [ ! -e heroes ]; then
11+
mkdir heroes
12+
cd heroes
13+
echo $hname > "${hname}.txt"
14+
echo "Level 1" >> "${hname}.txt"
15+
echo "Your hero will be Level 1 and henceforth be called ${hname}."
16+
else
17+
cd heroes
18+
echo $hname > "${hname}.txt"
19+
echo "Level 1" >> "${hname}.txt"
20+
echo "Your hero will be Level 1 and henceforth be called ${hname}."
21+
fi
22+
;;
23+
Strength)
24+
for (( c=0; c <= 4; c++ ))
25+
do
26+
echo "Rolling dice ... "
27+
sleep 1
28+
StrValue=$(($RANDOM%10-0))
29+
echo "Your Strength value is $StrValue ."
30+
let c++
31+
echo "Re-Roll your Strength [y/n]?"
32+
read q
33+
if [[ $q == "n" ]]; then
34+
let c=4
35+
fi
36+
done
37+
echo "Your heros Strength value of $StrValue was be saved."
38+
echo "Strength: ${StrValue}" >> Values.txt
39+
;;
40+
Dexterity)
41+
for (( c=0; c <= 4; c++ ))
42+
do
43+
echo "Rolling dice ... "
44+
sleep 1
45+
DexValue=$(($RANDOM%10-0))
46+
echo "Your Dexterity value is $DexValue ."
47+
let c++
48+
echo "Re-Roll your Dexterity [y/n]?"
49+
read q
50+
if [[ $q == "n" ]]; then
51+
let c=4
52+
fi
53+
done
54+
echo "Your heros Dexterity value of $DexValue was be saved."
55+
echo "Dexterity: ${DexValue}" >> Values.txt
56+
;;
57+
Intelligence)
58+
for (( c=0; c <= 4; c++ ))
59+
do
60+
echo "Rolling dice ... "
61+
sleep 1
62+
IntValue=$(($RANDOM%10-0))
63+
echo "Your Intelligence value is $IntValue ."
64+
let c++
65+
echo "Re-Roll your Intelligence [y/n]?"
66+
read q
67+
if [[ $q == "n" ]]; then
68+
let c=4
69+
fi
70+
done
71+
echo "Your heros Intelligence value of $IntValue was be saved."
72+
echo "Intelligence: ${IntValue}" >> Values.txt
73+
74+
;;
75+
Finish)
76+
if [ ! -e heroes ]; then
77+
mkdir heroes
78+
cd heroes
79+
else
80+
if [ -e "${hname}.txt" ]; then
81+
"Level 1" >> "${name}.txt"
82+
cat Values.txt >> "${hname}.txt"
83+
echo "Your hero has the following attributes: "
84+
cat "${hname}.txt"
85+
sleep 4
86+
echo "Your hero was saved to ${hname}.txt"
87+
#rm Values.txt
88+
cd ..
89+
break
90+
else
91+
echo "Your hero still needs a name. Please insert one now."
92+
read hname
93+
echo $hname > "${hname}.txt"
94+
cat Values.txt >> "${hname}.txt"
95+
echo "Your hero has the following attributes: "
96+
cat "${hname}.txt"
97+
sleep 4
98+
echo "Your hero was saved to ${hname}.txt."
99+
#rm Values.txt
100+
cd ..
101+
break
102+
fi
103+
fi
104+
;;
105+
esac
106+
done

0 commit comments

Comments
 (0)