From 2c1daa468eb3f97e59e01b50ca1a74f0ba9ae507 Mon Sep 17 00:00:00 2001 From: maggicl Date: Tue, 20 Nov 2018 18:34:42 +0000 Subject: [PATCH] team-leader: Added todororovic/ folder (content done by Alexander Todorovic) git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@289 a672b425-5310-4d7a-af5c-997e18724b81 --- todorovic/README.md | 8 ++++ todorovic/elif.html | 82 ++++++++++++++++++++++++++++++++++++++ todorovic/for.html | 62 ++++++++++++++++++++++++++++ todorovic/if-else.html | 69 ++++++++++++++++++++++++++++++++ todorovic/if.html | 73 +++++++++++++++++++++++++++++++++ todorovic/index.html | 60 ++++++++++++++++++++++++++++ todorovic/index_if.html | 52 ++++++++++++++++++++++++ todorovic/loops_index.html | 51 ++++++++++++++++++++++++ todorovic/mystyle.css | 43 ++++++++++++++++++++ todorovic/while.html | 66 ++++++++++++++++++++++++++++++ 10 files changed, 566 insertions(+) create mode 100644 todorovic/README.md create mode 100644 todorovic/elif.html create mode 100644 todorovic/for.html create mode 100644 todorovic/if-else.html create mode 100644 todorovic/if.html create mode 100644 todorovic/index.html create mode 100644 todorovic/index_if.html create mode 100644 todorovic/loops_index.html create mode 100644 todorovic/mystyle.css create mode 100644 todorovic/while.html diff --git a/todorovic/README.md b/todorovic/README.md new file mode 100644 index 0000000..4fea98d --- /dev/null +++ b/todorovic/README.md @@ -0,0 +1,8 @@ +# Files from Alexander Todorovic + +This folder contains work done by Alexander Todorovic, from the scripting team. +Due to abscence of whatsoever communication with Marco Conterno, the scripting +team team leader, these pages overlap with some of the content created by the +team members that volunteered to help the scripting team. These pages are also +not coded in Jekyll. For these reasons, everything in this folder is not in the +website and is kept just for grading purposes. diff --git a/todorovic/elif.html b/todorovic/elif.html new file mode 100644 index 0000000..41950f0 --- /dev/null +++ b/todorovic/elif.html @@ -0,0 +1,82 @@ + + + + + + + + + + elif|if + + +
+ +
+
+

syntax of first case

+

if [ expresion 1 ]
+ then
+ statement to be executed if expresion 1 is true
+ elif [ expression 2 ]
+ then
+ statement to be executed if expresion 2 is true
+ elif [ expression 3 ]
+ then
+ statement to be executed if expresion 3 is true
+ else
+ statement to be executed if no expresion is true
+ fi
+

+
+

Explanation

+

On can use this command (expression) if we want select one of many blocks of code to execute.
+ It check one by one the expression and when is true it execute the statement and goes to next.
+ But if the expressions are false then it enters into else block and execute the else statement + +

+ +

Exemple

+

#!/bin/sh
+ var1=10
+ var2=10
+ if[ var1==1var2 ]
+ then
+ echo "var1 is equal var2"
+ elif [ $var1 -gt $var2 ]
+ then
+ echo "var1 is greater than var2"
+ elif [ $var1 -lt $var2 ]
+ then
+ echo "var1 is not equal var2"
+ else
+ echo "none of the condition is ok"
+ fi
+

+ + + diff --git a/todorovic/for.html b/todorovic/for.html new file mode 100644 index 0000000..e913b02 --- /dev/null +++ b/todorovic/for.html @@ -0,0 +1,62 @@ + + + + + + + + + + for|loops + + +
+ +
+
+

syntax of For Loops

+

#!/bin/sh
+ for i in 1...N
+ do
+ Statement to be execudet for every word
+ done
+

+ +

Exemple

+ #!/bin/sh
+ for i in 1 2 3 4 5
+ echo "looping...number $1"
+ done
+ +

Explanation

+

The for loops iterate a throught a set of value, list of item until is finished.
+ Practicaly this loop repeat a set of commands for each item of the list

+ +
+ + + diff --git a/todorovic/if-else.html b/todorovic/if-else.html new file mode 100644 index 0000000..231e413 --- /dev/null +++ b/todorovic/if-else.html @@ -0,0 +1,69 @@ + + + + + + + + + + if-else|if + + +
+ +
+
+

syntax of if-else

+

if [ expresion ]
+ then
+ statement to be executed if expresion is true
+ else
+ statement to be executed if expresion is false
+ fi
+

+
+

Explanation

+

This espression run if the conditional is true, than it execute the statement 1.
+ If the result of conditional expression is zero, it jump to "else part" and execute the statement 2. Finally after the execution of if/else, it resume with the consequent statement.

+ + +
+

Exemple

+

#!/bin/sh
+ var1=10
+ var2=10 + if[ var1==1var2 ]
+ then
+ echo "var1 is equal var2"
+ else
+ echo "var1 is not equal var2"
+ fi +

+ + + diff --git a/todorovic/if.html b/todorovic/if.html new file mode 100644 index 0000000..697ba2a --- /dev/null +++ b/todorovic/if.html @@ -0,0 +1,73 @@ + + + + + + + + + + if|if + + +
+ +
+
+ +

syntax of if

+

if [ expresion ]
+ then
+ statement to be executed if expresion is true
+ fi
+

+
+

Important notice

+
    +
  • if expression is a shell comand, then it will be
    + assumed true if it return 0 after execution
  • +
  • If it is a boolean expression, then it would be true
    + if it returns true
  • +
  • Space between braces and expression it's important because
    + no space produce a syntax error
  • +
  • "fi"is "if backward
  • +
+
+

Exemple

+

#!/bin/sh
+ var1=20
+ var2=10 + if[ var1==1var2 ]
+ then
+ echo "var1 is equal var2"
+ fi + +

+ + + + diff --git a/todorovic/index.html b/todorovic/index.html new file mode 100644 index 0000000..78eae82 --- /dev/null +++ b/todorovic/index.html @@ -0,0 +1,60 @@ + + + + + + + + + + Home|index + + +
+ +
+
+

In the following pages we briefly descibe some interesting commands on Unix with exemple:

+
  • if +
      +
    • if-fi
    • +
    • if-else
    • +
    • if-elif
    • +
    +
  • +
  • loops +
      +
    • while
    • +
    • for
    • +
    +
  • +
    + + + + + diff --git a/todorovic/index_if.html b/todorovic/index_if.html new file mode 100644 index 0000000..f7a26b9 --- /dev/null +++ b/todorovic/index_if.html @@ -0,0 +1,52 @@ + + + + + + + + + + if|index + + +
    + +
    +
    +

    If

    +

    We have tree forms of if Statement:

    + +
  • if-fi statement
  • +
  • if-else statement
  • +
  • if-elif else if
  • + +

    The "if" command it's most often invoked to test virtually every shell script

    +
    + + + diff --git a/todorovic/loops_index.html b/todorovic/loops_index.html new file mode 100644 index 0000000..bc20e5a --- /dev/null +++ b/todorovic/loops_index.html @@ -0,0 +1,51 @@ + + + + + + + + + + loops|index + + +
    + +
    +
    +

    loops

    +

    In programming Languages Loops are important because this concept allows us
    + to repeat a task many times whitout repeat every time code

    + +
    + + + diff --git a/todorovic/mystyle.css b/todorovic/mystyle.css new file mode 100644 index 0000000..80c5721 --- /dev/null +++ b/todorovic/mystyle.css @@ -0,0 +1,43 @@ + +body {font-family: , Arial, Elvetica, sans-serif; + font-size: 15px; + line-height: 1.5; + padding: 0; + margin: 0;} + + + +ul { + margin: 0; + padding: 0; +} + +header { + background: #787878; + color: white; + padding-top: 20px; padding-bottom: -20px; + min-height: 70px; + border-bottom: #f0f0f0 3px solid; +} + +header a { + color: #ffffff; + text-decoration: none; + text-transform: uppercase; + font-size: 16px; +} + +header li { + float: left; + display: inline; + padding: 0 10px 0 10px; +} +.index { + margin: 10px; +} +.syntax { + margin: 10px; +} +.current a { + color: #000000; + font-weight: bold;} diff --git a/todorovic/while.html b/todorovic/while.html new file mode 100644 index 0000000..cddc96a --- /dev/null +++ b/todorovic/while.html @@ -0,0 +1,66 @@ + + + + + + + + + + while|loops + + +
    + +
    +
    +

    syntax of While Loops

    +

    #!/bin/sh
    + while [ comand ]
    + do
    + statement to be exeuted if command is true
    + done
    +

    + +

    Exemple

    + #!/bin/sh
    + INPUT_STRING=hello
    + while [ "$INPUT_STRING"!="bye" ]
    + do
    + echo "please type something in (bye to quit)
    + read INPUT_STRING
    + echo "You typed: $INPUT_STRING"
    + done
    + +

    Explanation

    +

    In this exemple "echo" and read statement run will go forward until we type "bye"
    + Normaly "while" command execute a code if this expression code is true, and stop only when is false or when say (type) stop.

    + +
    + + +