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:
parent
4bd44ca8e0
commit
fbe531398f
@ -1,9 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: page
|
layout: page
|
||||||
topic: The grep command
|
|
||||||
author: Domenico Votta
|
author: Domenico Votta
|
||||||
category_title: Advanced Commands
|
category-page: advanced
|
||||||
category_page: Advanced
|
category-title: Advanced commands
|
||||||
tags: search for occurences
|
tags: search for occurences
|
||||||
title: grep
|
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:
|
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>
|
<code>example1.txt</code>
|
||||||
{% highlight ruby linenos %}
|
{% highlight bash linenos %}
|
||||||
Car
|
Car
|
||||||
Computer
|
Computer
|
||||||
Robot
|
Robot
|
||||||
@ -20,7 +19,7 @@ Videogame
|
|||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
<code>example2.txt</code>
|
<code>example2.txt</code>
|
||||||
{% highlight ruby linenos %}
|
{% highlight bash linenos %}
|
||||||
Apple
|
Apple
|
||||||
Computer
|
Computer
|
||||||
Robot
|
Robot
|
||||||
@ -44,14 +43,14 @@ example2.txt: Robot
|
|||||||
|
|
||||||
<ul>
|
<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>
|
<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
|
grep -i robot example1.txt example2.txt
|
||||||
example1.txt: Robot
|
example1.txt: Robot
|
||||||
example2.txt: Robot
|
example2.txt: Robot
|
||||||
{% endhighlight %}
|
</pre>
|
||||||
|
|
||||||
<li> <b>-v</b>: this flag ignore the keyword from the search. </li>
|
<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
|
grep -i -v robot example1.txt example2.txt
|
||||||
example1.txt:Car
|
example1.txt:Car
|
||||||
example1.txt:Computer
|
example1.txt:Computer
|
||||||
@ -61,20 +60,20 @@ example2.txt:Apple
|
|||||||
example2.txt:Computer
|
example2.txt:Computer
|
||||||
example2.txt:Microsoft
|
example2.txt:Microsoft
|
||||||
example2.txt:Huawei
|
example2.txt:Huawei
|
||||||
{% endhighlight %}
|
</pre>
|
||||||
|
|
||||||
<li> <b>-c</b>: this flag indicates the number of times that the keyword appears in the file. </li>
|
<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
|
grep -i -c robot example1.txt
|
||||||
1
|
1
|
||||||
{% endhighlight %}
|
</pre>
|
||||||
<p> If in the file you would have had two times the keyword Robot, the output would have been 2</p>
|
<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>
|
<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
|
grep -i -h apple example1.txt example2.txt
|
||||||
Apple
|
Apple
|
||||||
{% endhighlight %}
|
</pre>
|
||||||
<p>How you can see the output doesn't show tha file name <code>example2.txt</code></p>
|
<p>How you can see the output doesn't show tha file name <code>example2.txt</code></p>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
---
|
---
|
||||||
layout: page
|
layout: page
|
||||||
topic: The nl command
|
|
||||||
author: Domenico Votta
|
author: Domenico Votta
|
||||||
category_title: Advanced Commands
|
category-page: advanced
|
||||||
category_page: Advanced
|
category-title: Advanced commands
|
||||||
tags: number lines
|
tags: number lines count
|
||||||
title: nl
|
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>
|
<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:
|
We have a file named <code>example.txt</code> that contains 5 elements, to test this command:
|
||||||
{% highlight ruby linenos %}
|
{% highlight bash linenos %}
|
||||||
Car
|
Car
|
||||||
Computer
|
Computer
|
||||||
Robot
|
Robot
|
||||||
@ -20,14 +19,14 @@ Videogame
|
|||||||
The syntax command is:
|
The syntax command is:
|
||||||
<pre> nl [flags][file] </pre>
|
<pre> nl [flags][file] </pre>
|
||||||
|
|
||||||
{% highlight ruby linenos %}
|
<pre>
|
||||||
nl example.txt
|
nl example.txt
|
||||||
1 Car
|
1 Car
|
||||||
2 Computer
|
2 Computer
|
||||||
3 Robot
|
3 Robot
|
||||||
4 Smartphone
|
4 Smartphone
|
||||||
5 Videogame
|
5 Videogame
|
||||||
{% endhighlight %}
|
</pre>
|
||||||
<p>How you can see the command has numbered the lines.</p>
|
<p>How you can see the command has numbered the lines.</p>
|
||||||
|
|
||||||
<h2>Flags</h2>
|
<h2>Flags</h2>
|
||||||
@ -36,35 +35,35 @@ nl example.txt
|
|||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
<li> <b>-b</b>: Specify the lines to be numered </li>
|
<li> <b>-b</b>: Specify the lines to be numered </li>
|
||||||
{% highlight ruby linenos %}
|
<pre>
|
||||||
nl -b p^[cv] example.txt
|
nl -b p^[cv] example.txt
|
||||||
1 Car
|
1 Car
|
||||||
2 Computer
|
2 Computer
|
||||||
3 Videogame
|
3 Videogame
|
||||||
Robot
|
Robot
|
||||||
Smartphone
|
Smartphone
|
||||||
{% endhighlight %}
|
</pre>
|
||||||
<p> <code>p^[cv]</code> says to nl to number only the lines that start with c and v.</p>
|
<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>
|
<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
|
nl -bn example.txt
|
||||||
Car
|
Car
|
||||||
Computer
|
Computer
|
||||||
Videogame
|
Videogame
|
||||||
Robot
|
Robot
|
||||||
Smartphone
|
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>
|
<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
|
nl -s= example.txt
|
||||||
1=Car
|
1=Car
|
||||||
2=Computer
|
2=Computer
|
||||||
3=Videogame
|
3=Videogame
|
||||||
4=Robot
|
4=Robot
|
||||||
5=Smartphone
|
5=Smartphone
|
||||||
{% endhighlight %}
|
</pre>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
|
@ -1,29 +1,28 @@
|
|||||||
---
|
---
|
||||||
layout: page
|
layout: page
|
||||||
topic: The pipes command
|
|
||||||
author: Domenico Votta
|
author: Domenico Votta
|
||||||
category_title: Advanced Commands
|
category-page: advanced
|
||||||
category_page: Advanced
|
category-title: Advanced commands
|
||||||
tags: pipes
|
tags: pipes redirect output input
|
||||||
title: pipes
|
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>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>
|
<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
|
ps aux | grep user
|
||||||
{% endhighlight %}
|
</pre>
|
||||||
<p>Lists all processes with your username</p>
|
<p>Lists all processes with your username</p>
|
||||||
|
|
||||||
{% highlight ruby linenos %}
|
<pre>
|
||||||
cat example1.txt | nl
|
cat example1.txt | nl
|
||||||
1 Car
|
1 Car
|
||||||
2 Computer
|
2 Computer
|
||||||
3 Robot
|
3 Robot
|
||||||
4 Smartphone
|
4 Smartphone
|
||||||
5 Videogame
|
5 Videogame
|
||||||
{% endhighlight %}
|
</pre>
|
||||||
<p>In this example you send this output to another process, in this case, the <a href="nl.html">nl</a> </p>
|
<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>
|
<p>You can use the commands that you learned and put them together, always respecting the logic of the command.</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user