advanced: code review for new pages
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@248 a672b425-5310-4d7a-af5c-997e18724b81
This commit is contained in:
parent
07c79772dd
commit
c4b3b2e4ef
2 changed files with 64 additions and 38 deletions
site/pages/cmd/advanced
|
@ -4,48 +4,39 @@ author: Agostino Monti
|
||||||
category-page: advanced
|
category-page: advanced
|
||||||
category-title: Advanced commands
|
category-title: Advanced commands
|
||||||
tags: head tail text file
|
tags: head tail text file
|
||||||
title: head-tail
|
title: head and tail
|
||||||
---
|
---
|
||||||
|
|
||||||
<br>
|
The <code>head</code> command reads the first few lines of any text given to it as an input
|
||||||
<br>
|
and writes them to standard output.<br>
|
||||||
<h3><code>head</code></h3>
|
If more than one input file is provided, head will return the first ten lines
|
||||||
<p>The <code>head</code> command reads the first few lines of any text given to it as an input
|
from each file, precede each set of lines by the name of the file and separate
|
||||||
and writes them to standard output.
|
each set of lines by one vertical space.
|
||||||
If more than one input file is provided, head will return the first ten lines
|
|
||||||
from each file, precede each set of lines by the name of the file and separate
|
|
||||||
each set of lines by one vertical space. </p>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<h3><code>tail</code></h3>
|
<pre>
|
||||||
<p>The tail command is similar to the head command
|
head [flags] [file1] [file2] ...
|
||||||
except that it reads the final lines in files rather than the first lines.</p>
|
</pre>
|
||||||
|
|
||||||
<h4>Examples</h4>
|
The <code>tail</code> command is similar to the <code>head</code> command
|
||||||
<p><pre>
|
except that it reads the final lines in files rather than the first lines.
|
||||||
head file1.txt <br>
|
|
||||||
head file1.txt file2.txt <br>
|
|
||||||
tail fail1.txt</pre></p>
|
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
tail [flags] [file1] [file2] ...
|
||||||
|
</pre>
|
||||||
|
|
||||||
<h3>flags</h3>
|
<h3>Flags</h3>
|
||||||
<ul>
|
|
||||||
<li>The <code>-n</code> option can be used followed by an integer indicating the number of lines desired.
|
|
||||||
-n is a very tolerant option, it is not necessary for the integer to directly
|
|
||||||
follow it without a space in between. In fact, the letter <i>n</i> does not
|
|
||||||
even need to be used at all. Just the hyphen and the integer
|
|
||||||
(with no intervening space) are sufficient to tell head how many lines to return.
|
|
||||||
<h4>Examples</h4>
|
|
||||||
<pre>
|
|
||||||
head -n15 file1.txt <br>
|
|
||||||
head -n 15 file1.txt <br>
|
|
||||||
head -15 file1.txt</pre></li>
|
|
||||||
|
|
||||||
<li>The output from other commands can be sent via a pipe (represented by the vertical bar character)
|
<ul>
|
||||||
to head to use as its input. The following sends the output from the ls command
|
<li><b>-n</b>: can be used followed by number, which indicates the number of
|
||||||
to head, which, in turn, displays the first ten lines of the output that it receives from ls
|
lines desired in the output. This flag can be used without <i>n</i>: the hyphen and the
|
||||||
<h4>Examples</h4>
|
number (with no intervening space) are enough to tell head how many lines to return.
|
||||||
<pre>
|
<pre>
|
||||||
ls | head </pre></li>
|
head -n15 file1.txt <br>
|
||||||
|
head -n 15 file1.txt <br>
|
||||||
</ul>
|
head -15 file1.txt</pre>
|
||||||
|
</li>
|
||||||
|
<li><b>-c</b>: similar to <i>-n</i> with the only difference being that the number stands for
|
||||||
|
bytes instead of the number of lines and the fact that it can't be used without explicitly
|
||||||
|
typing the <i>-c</i>.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
35
site/pages/cmd/advanced/paste.html
Normal file
35
site/pages/cmd/advanced/paste.html
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
---
|
||||||
|
layout: page
|
||||||
|
author: Agostino Monti
|
||||||
|
category-page: advanced
|
||||||
|
category-title: Advanced commands
|
||||||
|
tags: filie coluns analize
|
||||||
|
title: paste
|
||||||
|
---
|
||||||
|
|
||||||
|
The <code>paste</code> command is used to join files horizontally
|
||||||
|
(parallel merging) by outputting lines consisting of the sequentially corresponding
|
||||||
|
lines of each file specified, separated by tabs, to the standard output.<br>
|
||||||
|
Once involved, <code>paste</code> will read all its file arguments. For each corresponding line,
|
||||||
|
paste will append the contents of each file at that line to its output along with a tab.
|
||||||
|
When it has completed its operation for the last file, <code>paste</code> will output a newline
|
||||||
|
character and move on to the next line.
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
paste [flags] [file1] [file2] ...
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h3>Flags</h3>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><code>-d</code> delimiters, which specifies a list of delimiters to be used instead of tabs
|
||||||
|
for separating consecutive values on a single line. Each delimiter is used in turn;
|
||||||
|
when the list has been exhausted, paste begins again at the first delimiter.
|
||||||
|
<pre>
|
||||||
|
paste -d "|" file1.txt file2.txt
|
||||||
|
paste -d "|," file1.txt file2.txt</pre>
|
||||||
|
</li>
|
||||||
|
<li><code>-s</code>, which causes paste to append the data in serial rather than in parallel;
|
||||||
|
that is, in a horizontal rather than vertical fashion.
|
||||||
|
</li>
|
||||||
|
</ul>
|
Loading…
Reference in a new issue