css-team: spellcheck
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@280 a672b425-5310-4d7a-af5c-997e18724b81
This commit is contained in:
parent
e3fa1d2eba
commit
64f1910f34
7 changed files with 33 additions and 33 deletions
|
@ -9,8 +9,8 @@ next-page: pages/scripts/1-variables.html
|
|||
---
|
||||
<!-- Echo command text -->
|
||||
<h3>Echo</h3>
|
||||
<p>This command print as output its entire argument on the command-line.<br>
|
||||
It could be used with variables, like in the following example:<br>
|
||||
<p>This command prints its entire argument as output on the command-line.<br>
|
||||
It can be used with variables, like in the following example:<br>
|
||||
|
||||
<pre>
|
||||
example="this is an example"
|
||||
|
@ -22,10 +22,10 @@ echo $example
|
|||
<!-- Cat command text -->
|
||||
<h3>Cat</h3>
|
||||
|
||||
This command prints the content of a certain file as an output on the
|
||||
This command prints the content of a certain file as output on the
|
||||
command-line.<br>
|
||||
|
||||
As example, we could imagine a simple text file in nano named "Hello", which contains
|
||||
For example, we could imagine a simple text file in nano named "Hello", which contains
|
||||
the line "Hello World".<br>
|
||||
So, our command example will look like this:<br>
|
||||
|
||||
|
|
|
@ -10,13 +10,13 @@ next-page: pages/scripts/2-special-variables.html
|
|||
---
|
||||
<!-- Intro -->
|
||||
A variable is simply a string to which we assign a certain type of data,
|
||||
which could be a text, a number, a filename and other types of data.<br>
|
||||
which could be some text, a number, a filename or other types of data.<br>
|
||||
|
||||
<!-- How to name a variable - text -->
|
||||
<h3>Naming a variable</h3>
|
||||
|
||||
<!-- Explaination -->
|
||||
To name a variable in Unix we have to use only letters, numbers or
|
||||
To name a variable in Unix we can only use letters, numbers or
|
||||
the underscore character (_).<br>
|
||||
Other characters can't be used because they have a special meaning in Unix Shell.<br>
|
||||
|
||||
|
@ -32,7 +32,7 @@ name_4
|
|||
<!-- How to define a variable - text -->
|
||||
<h3>Defining a variable</h3>
|
||||
|
||||
To define a certain variable, we could use the following basecase:
|
||||
To define a certain variable, we use the following base case:
|
||||
|
||||
<pre>
|
||||
variable_name=variable_value
|
||||
|
@ -58,7 +58,7 @@ echo $VAR_1
|
|||
<!-- How to delete a variable - text -->
|
||||
<h3>Deleting a variable</h3>
|
||||
|
||||
Deleting a variable means that shell will remove a certain variable from the list of
|
||||
Deleting a variable means that the shell will remove a certain variable from the list of
|
||||
those that it tracks.<br>
|
||||
To delete a variable we use the following command:
|
||||
|
||||
|
@ -75,7 +75,7 @@ unset VAR_1
|
|||
<!-- How to protect a variable - text -->
|
||||
<h3>Protecting variables</h3>
|
||||
|
||||
To protect a certain variable, we can set them as read-only so that it can't be
|
||||
To protect a certain variable, we can set it as read-only so that it can't be
|
||||
changed or deleted.<br>
|
||||
So, if we try to change the value of VAR_1, the result will be the following:
|
||||
|
||||
|
@ -86,7 +86,7 @@ VAR_1="Blueberry"
|
|||
VAR_1: This variable is read only.
|
||||
</pre>
|
||||
|
||||
If we try to delete the variable, shell will give us the following value:
|
||||
If we try to delete the variable, the shell will give us the following error:
|
||||
|
||||
<pre>
|
||||
VAR_1="Strawberry"
|
||||
|
|
|
@ -9,12 +9,12 @@ previous-page: pages/scripts/1-variables.html
|
|||
next-page: pages/scripts/3-parameter_expansion.html
|
||||
---
|
||||
<!-- Intro -->
|
||||
There are certain strings that we can not use in the variable-naming process.<br>
|
||||
In this page we will see what actually are those strings, and what's their purpose.<br>
|
||||
There are certain strings that we can't use in the variable-naming process.<br>
|
||||
In this page we will see what those strings are, and what their purpose is.<br>
|
||||
|
||||
<h4>$$</h4>
|
||||
To begin, we will see the simplest variable, which is the dollar sign ($).
|
||||
This command simply gives us the process ID number of the current shell.<br>
|
||||
To begin, we look at the simplest variable, which is the dollar sign ($).
|
||||
This command simply gives us the process ID of the current shell.<br>
|
||||
|
||||
<pre>
|
||||
echo $$
|
||||
|
@ -22,7 +22,7 @@ echo $$
|
|||
</pre>
|
||||
|
||||
<h4>$0</h4>
|
||||
This variable will simply give us the filename of the current script.
|
||||
This variable simply gives us the filename of the current script.
|
||||
|
||||
<h4>$n</h4>
|
||||
This variable corresponds to the arguments with which a script was invoked.
|
||||
|
@ -32,4 +32,4 @@ Here n is a positive number corresponding to the position of an argument.
|
|||
This variable gives us the number of arguments supplied to a script.
|
||||
|
||||
<h4>$!</h4>
|
||||
This variable gives us the process number of the last background command.
|
||||
This variable gives us the process ID of the last background command.
|
||||
|
|
|
@ -60,7 +60,7 @@ There are also other ways to specify the <i> numerical range </i>. For instance,
|
|||
your numerical range is too big, you can simply write: <code> {1..100} </code>. This piece
|
||||
of code means every natural number between 1 and 100 (both included). <br>
|
||||
Ranges can also count backward like this: <code>{10..1}</code>.
|
||||
You can even increment the numerical value by step of two: <code> {0..10..2} </code>.
|
||||
This piece of code means every natural number between 0 and 10 with a step of two,
|
||||
You can even increment the numerical value by steps of two: <code> {0..10..2} </code>.
|
||||
This piece of code means every natural number between 0 and 10 in steps of two;
|
||||
0 2 4 6... 10.
|
||||
<!-- End of Explanation of Numerical Range -->
|
||||
|
|
|
@ -31,7 +31,7 @@ done
|
|||
<!-- End of Introduction -->
|
||||
|
||||
<!-- First Example -->
|
||||
Here is a first simple example:
|
||||
Here is a simple first example:
|
||||
{% highlight bash %}
|
||||
i=0;
|
||||
|
||||
|
@ -80,8 +80,8 @@ do
|
|||
done
|
||||
{% endhighlight %}
|
||||
|
||||
No termination condition is set for this loop in this example. This type of loop
|
||||
is called infinite loop.<br>
|
||||
No termination condition is set for the loop in this example. This type of loop
|
||||
is called an infinite loop.<br>
|
||||
The <code> exit</code> statement is used to quit the loop. This loop will
|
||||
iterate for 9 times, then
|
||||
as soon as <code> i</code> becomes equal to 0, the condition of the last if
|
||||
|
|
|
@ -11,7 +11,7 @@ next-page: pages/scripts/8-redirection.html
|
|||
|
||||
<!-- Introduction -->
|
||||
If statements allow us to make decisions in our Bash scripts. They allow us to
|
||||
whether run or not a piece of code based on a condition that we set. <br>
|
||||
decide whether or not to run a piece of code based on a condition that we set. <br>
|
||||
|
||||
If statements take this form:
|
||||
{% highlight bash %}
|
||||
|
@ -39,7 +39,7 @@ In this first example we evaluate a variable <code>i</code> to 105.
|
|||
The <i> if statement </i> will print "You chose a big number"
|
||||
only if the number contained in our variable <code>i</code> is <b>G</b>reater or
|
||||
<b>E</b>qual to 200. <br>
|
||||
This is our case, therefore the output of this piece of code will be:
|
||||
This is the case, therefore the output of this piece of code will be:
|
||||
<pre>
|
||||
You chose a big number.
|
||||
</pre>
|
||||
|
@ -52,7 +52,7 @@ This is our case, therefore the output of this piece of code will be:
|
|||
Sometimes we want to perform a certain set of actions, if our condition evaluates to
|
||||
true and another set of actions if our condition evaluates to false. We can do this with
|
||||
the <i> if else </i> statement.
|
||||
<i> if else </i> sattements take this form:
|
||||
<i> if else </i> statements take this form:
|
||||
{% highlight bash %}
|
||||
if [condition]; then
|
||||
command1
|
||||
|
@ -78,10 +78,10 @@ else
|
|||
fi
|
||||
{% endhighlight %}
|
||||
|
||||
In this example, that is just an extension of the previous example, we
|
||||
In this example, which is just an extension of the previous example, we
|
||||
evaluate a variable <code>i</code> to 50. If <code>i</code> is greater or equal to
|
||||
200, you print out "You chose a big number", otherwise,
|
||||
(if <code>i</code> is not greater or equal to 200), just like in this case, you print out
|
||||
200, we print out "You chose a big number", otherwise,
|
||||
(if <code>i</code> is not greater or equal to 200), just like in this case, we print out
|
||||
"You chose a small number".
|
||||
Therefore, the output of this piece of code is:
|
||||
|
||||
|
@ -130,7 +130,7 @@ else
|
|||
fi
|
||||
{% endhighlight %}
|
||||
|
||||
In this example, that is just an extension of the previous example, we evaluate a
|
||||
In this example, which is just an extension of the previous example, we evaluate a
|
||||
variable <code>i</code> to 150. If <code>i</code> is greater or equal to 200,
|
||||
you print out "You chose a big number", if <code>i</code> is equal to 150 you print out
|
||||
"You chose 150" otherwise you print out "You chose a small number".
|
||||
|
|
|
@ -9,7 +9,7 @@ previous-page: pages/scripts/7-if.html
|
|||
---
|
||||
<h3>output as input</h3>
|
||||
<br>
|
||||
To redirect a certain output of the command-line we have to use the symbol ">".<br>
|
||||
To redirect the output of a command we use the symbol ">".<br>
|
||||
|
||||
In this case, we will use a file named <i>hello.txt</i>, in which we want to insert
|
||||
a certain output ("Sun" in this case):<br>
|
||||
|
@ -40,10 +40,10 @@ cat hello.txt
|
|||
<!-- Input redirection text -->
|
||||
<h3>input as output</h3>
|
||||
<br>
|
||||
To redirect an input from a file for a command, the symbol "<" is used.
|
||||
To redirect input from a file for a command, the symbol "<" is used.
|
||||
|
||||
<pre>
|
||||
echo $lt; $(cat hello.txt)
|
||||
echo < $(cat hello.txt)
|
||||
Sun
|
||||
Moon
|
||||
</pre>
|
||||
|
@ -54,7 +54,7 @@ This is particularly useful when chaining commands.<br>
|
|||
<h3>Chaining (or piping)</h3>
|
||||
|
||||
Chaining, also called Piping because it works with the pipe symbol "|", takes
|
||||
the output of a certain command-line and feeds it to another command in a direct way.
|
||||
the output of a certain command and feeds it to another command.
|
||||
<pre>
|
||||
cat hello.txt | grep Mo
|
||||
Moon
|
||||
|
@ -63,7 +63,7 @@ Moon
|
|||
<h3>A simple example</h3>
|
||||
|
||||
Now let's say that we want to combine those commands in a more complex operation.
|
||||
Let's say we want to take some contents from a certain file and put it into another file.<br>
|
||||
Let's say we want to take the content of a certain file and put it into another file.<br>
|
||||
|
||||
We want to sort the animals whose name begins with letter "d" from the file
|
||||
<i>animals.txt</i> and put it into <i>d_animals.txt</i>.<br>
|
||||
|
|
Loading…
Reference in a new issue