advanced: fix header and pre tag usage

git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@105 a672b425-5310-4d7a-af5c-997e18724b81
This commit is contained in:
bevilj 2018-11-11 16:47:25 +00:00
parent 4bd44ca8e0
commit fbe531398f
3 changed files with 32 additions and 35 deletions

View File

@ -1,9 +1,8 @@
---
layout: page
topic: The grep command
author: Domenico Votta
category_title: Advanced Commands
category_page: Advanced
category-page: advanced
category-title: Advanced commands
tags: search for occurences
title: grep
---
@ -11,7 +10,7 @@ title: grep
Here we have two files named <code>example1.txt</code> and <code>example2.txt</code> that contain 5 elements, to test this command:
<code>example1.txt</code>
{% highlight ruby linenos %}
{% highlight bash linenos %}
Car
Computer
Robot
@ -20,7 +19,7 @@ Videogame
{% endhighlight %}
<code>example2.txt</code>
{% highlight ruby linenos %}
{% highlight bash linenos %}
Apple
Computer
Robot
@ -44,14 +43,14 @@ example2.txt: Robot
<ul>
<li> <b>-i</b>: this flag ignore the case sensitive. Here we can write Robot or robot that grep will find the correspondence. </li>
{% highlight ruby linenos %}
<pre>
grep -i robot example1.txt example2.txt
example1.txt: Robot
example2.txt: Robot
{% endhighlight %}
</pre>
<li> <b>-v</b>: this flag ignore the keyword from the search. </li>
{% highlight ruby linenos %}
<pre>
grep -i -v robot example1.txt example2.txt
example1.txt:Car
example1.txt:Computer
@ -61,20 +60,20 @@ example2.txt:Apple
example2.txt:Computer
example2.txt:Microsoft
example2.txt:Huawei
{% endhighlight %}
</pre>
<li> <b>-c</b>: this flag indicates the number of times that the keyword appears in the file. </li>
{% highlight ruby linenos %}
<pre>
grep -i -c robot example1.txt
1
{% endhighlight %}
</pre>
<p> If in the file you would have had two times the keyword Robot, the output would have been 2</p>
<li> <b>-h</b>: Remove from the output the file name where it found the keyword</li>
{% highlight ruby linenos %}
<pre>
grep -i -h apple example1.txt example2.txt
Apple
{% endhighlight %}
</pre>
<p>How you can see the output doesn't show tha file name <code>example2.txt</code></p>
</ul>

View File

@ -1,15 +1,14 @@
---
layout: page
topic: The nl command
author: Domenico Votta
category_title: Advanced Commands
category_page: Advanced
tags: number lines
category-page: advanced
category-title: Advanced commands
tags: number lines count
title: nl
---
<p>The <code>nl</code> is a command that permits to number the lines. Through some flags you can decide how to filter this command.</p>
We have a file named <code>example.txt</code> that contains 5 elements, to test this command:
{% highlight ruby linenos %}
{% highlight bash linenos %}
Car
Computer
Robot
@ -20,14 +19,14 @@ Videogame
The syntax command is:
<pre> nl [flags][file] </pre>
{% highlight ruby linenos %}
<pre>
nl example.txt
1 Car
2 Computer
3 Robot
4 Smartphone
5 Videogame
{% endhighlight %}
</pre>
<p>How you can see the command has numbered the lines.</p>
<h2>Flags</h2>
@ -36,35 +35,35 @@ nl example.txt
<ul>
<li> <b>-b</b>: Specify the lines to be numered </li>
{% highlight ruby linenos %}
<pre>
nl -b p^[cv] example.txt
1 Car
2 Computer
3 Videogame
Robot
Smartphone
{% endhighlight %}
</pre>
<p> <code>p^[cv]</code> says to nl to number only the lines that start with c and v.</p>
<li> -b<b>n</b>: The flag n goes with b, doesn't number any lines </li>
{% highlight ruby linenos %}
<pre>
nl -bn example.txt
Car
Computer
Videogame
Robot
Smartphone
{% endhighlight %}
</pre>
<li> <b>-s</b>: Usually nl separes the number of the line from the text with a tab, with -s flag you can choose another separator, in this example we will use "=". </li>
{% highlight ruby linenos %}
<pre>
nl -s= example.txt
1=Car
2=Computer
3=Videogame
4=Robot
5=Smartphone
{% endhighlight %}
</pre>
</ul>
</p>

View File

@ -1,29 +1,28 @@
---
layout: page
topic: The pipes command
author: Domenico Votta
category_title: Advanced Commands
category_page: Advanced
tags: pipes
category-page: advanced
category-title: Advanced commands
tags: pipes redirect output input
title: pipes
---
<p>The <code>pipes</code> that in the shell are representend with the symbol | , they are used to join two commands on the terminal, taking the output of the first command and using it as input of the second. </p>
<p> It is usually common to see the command grep and ps together, an example below.</p>
{% highlight ruby linenos %}
<pre>
ps aux | grep user
{% endhighlight %}
</pre>
<p>Lists all processes with your username</p>
{% highlight ruby linenos %}
<pre>
cat example1.txt | nl
1 Car
2 Computer
3 Robot
4 Smartphone
5 Videogame
{% endhighlight %}
<p>In this example you send this output to another process, in this case, the <a href="nl.html">nl</a> </p>
</pre>
<p>In this example you send this output to another process, in this case, the <a href="{{ site.baseurl }}/pages/cmd/advanced/nl.html">nl</a> </p>
<p>You can use the commands that you learned and put them together, always respecting the logic of the command.</p>