Skip to content

Commit 235cb23

Browse files
committed
Updated index, formatting of scripts.
1 parent aedc3a2 commit 235cb23

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<body>
99
<h1>Kurz práce v příkazové řádce Linuxu nejen pro MetaCentrum<br />Course of work in Linux command line not only for MetaCentrum</h1>
1010
<p>
11-
<a href="https://trapa.cz/cs/kurz-prikazove-radky-linuxu-2016" type="text/html"><big><strong>Jděte na stránku kurzu</strong></big></a> (<a href="https://github.com/V-Z/course-linux-command-line-bash-scripting-metacentrum/" type="text/html">nejnovější pracovní verze</a>) - <a href="https://is.cuni.cz/studium/predmety/index.php?do=predmet&amp;kod=MB120C17" type="text/html">předmět v SIS</a>
11+
<a href="https://trapa.cz/cs/kurz-prikazove-radky-linuxu-2018" type="text/html"><big><strong>Jděte na stránku kurzu</strong></big></a> (<a href="https://github.com/V-Z/course-linux-command-line-bash-scripting-metacentrum/" type="text/html">nejnovější pracovní verze</a>) - <a href="https://is.cuni.cz/studium/predmety/index.php?do=predmet&amp;kod=MB120C17" type="text/html">předmět v SIS</a>
1212
</p>
1313
<p>
14-
<a href="https://trapa.cz/en/course-linux-command-line-2016" type="text/html"><big><strong>Go to the course web page</strong></big></a> (<a href="https://github.com/V-Z/course-linux-command-line-bash-scripting-metacentrum/" type="text/html">newest working version</a>) - <a href="https://is.cuni.cz/studium/eng/predmety/index.php?do=predmet&amp;kod=MB120C17" type="text/html">subject in SIS</a>
14+
<a href="https://trapa.cz/en/course-linux-command-line-2018" type="text/html"><big><strong>Go to the course web page</strong></big></a> (<a href="https://github.com/V-Z/course-linux-command-line-bash-scripting-metacentrum/" type="text/html">newest working version</a>) - <a href="https://is.cuni.cz/studium/eng/predmety/index.php?do=predmet&amp;kod=MB120C17" type="text/html">subject in SIS</a>
1515
</p>
1616
</body>
1717
</html>

scripts/interactive3.sh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
# "case" is evaluating provided parameter and behaving accordingly
55

66
case "$1" in
7-
# "|" means alternatives - more possible inputs
8-
-d|--disk)
9-
echo "Your disk usage is:"
10-
df -h
11-
;;
12-
-u|--uptime)
13-
echo "Your computer is running:"
14-
uptime
15-
;;
16-
# This should be every time last possibility - any other input
17-
# User is then notified he entered nonsense and gets some help
18-
*) # Any other input
19-
echo "Wrong option!"
20-
echo "Usage: -d or --disk for available disk space or"
21-
echo "-u or --uptime for computer uptime"
22-
# In this case, exit with error code 1
23-
exit 1
24-
;;
25-
esac
7+
# "|" means alternatives - more possible inputs
8+
-d|--disk)
9+
echo "Your disk usage is:"
10+
df -h
11+
;;
12+
-u|--uptime)
13+
echo "Your computer is running:"
14+
uptime
15+
;;
16+
# This should be every time last possibility - any other input
17+
# User is then notified he entered nonsense and gets some help
18+
*) # Any other input
19+
echo "Wrong option!"
20+
echo "Usage: -d or --disk for available disk space or"
21+
echo "-u or --uptime for computer uptime"
22+
# In this case, exit with error code 1
23+
exit 1
24+
;;
25+
esac
2626

2727
exit

scripts/interactive4.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,39 @@ NUMBER='^[0-9]+$'
77

88
# Function to print help - we will use it twice
99
function usagehelp {
10-
echo "Usage: number1 plus/minus/product/quotient number2"
11-
echo "Use plus for sum, minus for difference, product"
12-
echo "for multiplication or quotient for quotient."
13-
exit 1 # End up with an error
14-
}
10+
echo "Usage: number1 plus/minus/product/quotient number2"
11+
echo "Use plus for sum, minus for difference, product"
12+
echo "for multiplication or quotient for quotient."
13+
exit 1 # End up with an error
14+
}
1515

1616
# Do we have 3 parameters provided?
1717
if [ "$#" -ne "3" ]; then
18-
echo "Error! Requiring 3 parameters! Received $# ($*)."
19-
usagehelp # The function to print help
20-
fi
18+
echo "Error! Requiring 3 parameters! Received $# ($*)."
19+
usagehelp # The function to print help
20+
fi
2121

2222
# "=~" means we are testing if $1 fits to regular expression in $NUMBER
2323
# Is parameter 1 number?
2424
if [[ ! $1 =~ $NUMBER ]]; then
25-
echo "Parameter 1 is not an integer!"
26-
usagehelp # The function to print help
27-
fi
25+
echo "Parameter 1 is not an integer!"
26+
usagehelp # The function to print help
27+
fi
2828

2929
# Is parameter 3 number?
3030
if [[ ! $3 =~ $NUMBER ]]; then
31-
echo "Parameter 3 is not an integer!"
32-
usagehelp # The function to print help
33-
fi
31+
echo "Parameter 3 is not an integer!"
32+
usagehelp # The function to print help
33+
fi
3434

3535
case "$2" in
36-
plus) expr $1 '+' $3;;
37-
minus) expr $1 '-' $3;;
38-
product) expr $1 '*' $3;;
39-
quotient) expr $1 '/' $3;;
40-
*) echo "Wrong option!"
41-
usagehelp # The function to print help
42-
;;
43-
esac
36+
plus) expr $1 '+' $3;;
37+
minus) expr $1 '-' $3;;
38+
product) expr $1 '*' $3;;
39+
quotient) expr $1 '/' $3;;
40+
*) echo "Wrong option!"
41+
usagehelp # The function to print help
42+
;;
43+
esac
4444

4545
exit

0 commit comments

Comments
 (0)