aboutsummaryrefslogtreecommitdiff
path: root/it_IT.ISO8859-15/books/unix-introduction/special-features/chapter.xml
diff options
context:
space:
mode:
Diffstat (limited to 'it_IT.ISO8859-15/books/unix-introduction/special-features/chapter.xml')
-rw-r--r--it_IT.ISO8859-15/books/unix-introduction/special-features/chapter.xml556
1 files changed, 556 insertions, 0 deletions
diff --git a/it_IT.ISO8859-15/books/unix-introduction/special-features/chapter.xml b/it_IT.ISO8859-15/books/unix-introduction/special-features/chapter.xml
new file mode 100644
index 0000000000..d5f6144716
--- /dev/null
+++ b/it_IT.ISO8859-15/books/unix-introduction/special-features/chapter.xml
@@ -0,0 +1,556 @@
+<?xml version="1.0" encoding="iso-8859-15" standalone="no"?>
+<!--
+ The FreeBSD Italian Documentation Project
+
+ $FreeBSD$
+-->
+
+<chapter id="special-features">
+ <title>Caratteristiche speciali di Unix</title>
+
+ <para>Uno dei più importanti contributi che Unix ha dato ai sistemi
+ operativi è stato quello di fornire molti strumenti per creare lavori
+ ordinari e per ottenere le informazioni che si desiderano. Un altro
+ è rappresentato dal modo standard con cui i dati sono memorizzati e
+ trasmessi in un sistema Unix. Questo permette di trasferire dati
+ <emphasis>in</emphasis> un file, nel terminale video o in un programma,
+ oppure <emphasis>da</emphasis> un file, dalla tastiera o da un programma,
+ sempre in maniera uniforme. Il trattamento standardizzato dei dati supporta
+ due importanti caratteristiche di Unix: la redirezione di I/O e il
+ piping.</para>
+
+ <para>Con la <emphasis>redirezione dell'output</emphasis>, l'output di un
+ comando viene rediretto su un file piuttosto che sul terminale video.
+ Con la <emphasis>redirezione dell'input</emphasis>, l'input di un comando
+ viene preso da un file piuttosto che dalla tastiera. Sono possibili
+ altre tecniche di redirezione dell'input e dell'output come
+ si vedrà in seguito. Con il <emphasis>piping</emphasis>, l'output di
+ un comando può essere usato come input di un comando successivo.
+ In questo capitolo si discuterà di alcune delle caratteristiche e
+ degli strumenti disponibili per gli utenti Unix.</para>
+
+ <sect1 id="special-features-file-desc">
+ <title>Descrittori di file</title>
+
+ <para>Ci sono 3 descrittori di file standard:</para>
+
+ <informaltable frame="none">
+ <tgroup cols="3">
+ <colspec colwidth="1in"/>
+
+ <colspec colwidth="0.5in"/>
+
+ <tbody>
+ <row>
+ <entry>&man.stdin.4;</entry>
+
+ <entry>0</entry>
+
+ <entry>Standard input per il programma</entry>
+ </row>
+
+ <row>
+ <entry>&man.stdout.4;</entry>
+
+ <entry>1</entry>
+
+ <entry>Standard output dal programma</entry>
+ </row>
+
+ <row>
+ <entry>&man.stderr.4;</entry>
+
+ <entry>2</entry>
+
+ <entry>Standard error (output) dal programma</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <para>Normalmente l'input viene preso dalla tastiera o da un file.
+ Generalmente l'output, sia &man.stdout.4; che &man.stderr.4;, scorre nel
+ terminale, ma può essere rediretto, uno o entrambi, su uno o
+ più file.</para>
+
+ <para>Si possono specificare descrittori di file addizionali, denotandoli
+ con un numero da 3 a 9 e redirigendo l'I/O attraverso questi.</para>
+ </sect1>
+
+ <sect1 id="special-features-file-redir">
+ <title>Redirezione di file</title>
+
+ <para>La redirezione dell'output prende l'output di un comando e lo
+ posiziona nel file specificato. La redirezione dell'input legge il file
+ specificato come input per un comando. La tabella che segue sintetizza le
+ possibili modalità di redirezione.</para>
+
+ <table frame="all" id="special-features-table-file-redir">
+ <title>Redirezione di file</title>
+
+ <tgroup cols="2">
+ <colspec colwidth="1.5in"/>
+
+ <thead>
+ <row>
+ <entry align="center">SIMBOLO</entry>
+
+ <entry align="center">REDIREZIONE</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><command>&gt;</command></entry>
+
+ <entry>redirezione dell'output</entry>
+ </row>
+
+ <row>
+ <entry><command>&gt;!</command></entry>
+
+ <entry>come sopra, ma non tiene conto dell'opzione
+ <emphasis>noclobber</emphasis> per &man.csh.1;</entry>
+ </row>
+
+ <row>
+ <entry><command>&gt;&gt;</command></entry>
+
+ <entry>appende l'output</entry>
+ </row>
+
+ <row>
+ <entry><command>&gt;&gt;!</command></entry>
+
+ <entry>come sopra, ma non tiene conto dell'opzione
+ <emphasis>noclobber</emphasis> su &man.csh.1; e crea il file se
+ non esiste</entry>
+ </row>
+
+ <row>
+ <entry><command>|</command></entry>
+
+ <entry>incanala (pipe) l'output nell'input di un altro
+ comando</entry>
+ </row>
+
+ <row>
+ <entry><command>&lt;</command></entry>
+
+ <entry>redirezione dell'input</entry>
+ </row>
+
+ <row>
+ <entry><command>&lt;&lt;<replaceable>Stringa</replaceable></command></entry>
+
+ <entry>legge da standard input fino a quando incontra una linea
+ contenente solo la parola <replaceable>Stringa</replaceable>.
+ Anche conosciuto come <emphasis>here document</emphasis>
+ (vedere il <link
+ linkend="shell-programming">Capitolo 9</link>)</entry>
+ </row>
+
+ <row>
+ <entry><command>&lt;&lt;\<replaceable>Stringa</replaceable></command></entry>
+
+ <entry>come sopra, ma le sostituzioni di shell non sono
+ permesse</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>Un esempio di redirezione dell'output è:</para>
+
+ <para><command>cat <replaceable>file1 file2</replaceable> &gt;
+ <replaceable>file3</replaceable></command></para>
+
+ <para>Il precedente comando concatena
+ <filename><replaceable>file1</replaceable></filename>
+ e <filename><replaceable>file2</replaceable></filename> e redirige (manda)
+ l'output in <filename><replaceable>file3</replaceable></filename>. Se
+ <filename><replaceable>file3</replaceable></filename> non esiste, viene
+ creato. Se esiste, verrà troncato a lunghezza zero prima che il
+ nuovo contenuto sia inserito, oppure, se l'opzione
+ <emphasis>noclobber</emphasis> della shell &man.csh.1; è abilitata,
+ il comando verrà rifiutato (vedere la shell &man.csh.1; nel
+ <link linkend="shells">Capitolo 5</link>). I file originali
+ <filename><replaceable>file1</replaceable></filename> e
+ <filename><replaceable>file2</replaceable></filename> rimarranno
+ come erano prima dell'esecuzione del comando, ossia due entità
+ separate.</para>
+
+ <para>L'output viene appeso a un file con la forma:</para>
+
+ <para><command>cat <replaceable>file1</replaceable> &gt;&gt;
+ <replaceable>file2</replaceable></command></para>
+
+ <para>Questo comando appende il contenuto di
+ <filename><replaceable>file1</replaceable></filename> alla fine
+ dell'esistente <filename><replaceable>file2</replaceable></filename>
+ (<filename><replaceable>file2</replaceable></filename> non viene
+ soprascritto).</para>
+
+ <para>L'input è rediretto (preso) da un file con la forma:</para>
+
+ <para><command><replaceable>programma</replaceable> &lt;
+ <replaceable>file</replaceable></command></para>
+
+ <para>Questo comando prende l'input per il
+ <command><replaceable>programma</replaceable></command> da
+ <filename><replaceable>file</replaceable></filename>.</para>
+
+ <para>Per incanalare (pipe) l'output di un programma nell'input di un altro
+ programma si usa la forma:</para>
+
+ <para><command><replaceable>comando</replaceable>|<replaceable>comando</replaceable></command></para>
+
+ <para>Questo comando assegna l'output del primo comando all'input del
+ secondo comando.</para>
+
+ <sect2 id="special-features-file-redir-csh">
+ <title>Csh</title>
+
+ <informaltable frame="none">
+ <tgroup cols="2">
+ <colspec colwidth="2in"/>
+
+ <tbody>
+ <row>
+ <entry><command>&gt;&amp;
+ <replaceable>file</replaceable></command></entry>
+
+ <entry>redirige &man.stdout.4; e &man.stderr.4; in
+ <filename><replaceable>file</replaceable></filename></entry>
+ </row>
+
+ <row>
+ <entry><command>&gt;&gt;&amp;
+ <replaceable>file</replaceable></command></entry>
+
+ <entry>appende &man.stdout.4; e &man.stderr.4; in
+ <filename><replaceable>file</replaceable></filename></entry>
+ </row>
+
+ <row>
+ <entry><command>|&amp;
+ <replaceable>comando</replaceable></command></entry>
+
+ <entry>crea una pipe tra &man.stdout.4;-&man.stderr.4; e il
+ <command><replaceable>comando</replaceable></command></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <para>Per redirigere &man.stdout.4; e &man.stderr.4; in due file separati
+ si deve prima redirigere &man.stdout.4; in una sotto-shell,
+ così:</para>
+
+ <screen>&prompt.user; <userinput>(<replaceable>comando</replaceable> > <replaceable>out_file</replaceable>) >& <replaceable>err_file</replaceable></userinput></screen>
+ </sect2>
+
+ <sect2 id="special-features-file-redir-sh">
+ <title>Sh</title>
+
+ <informaltable frame="none">
+ <tgroup cols="2">
+ <colspec colwidth="2in"/>
+
+ <tbody>
+ <row>
+ <entry><command>2&gt;
+ <replaceable>file</replaceable></command></entry>
+
+ <entry>redirige &man.stderr.4; in
+ <filename><replaceable>file</replaceable></filename></entry>
+ </row>
+
+ <row>
+ <entry><command>&gt; <replaceable>file</replaceable>
+ 2&gt;&amp;1</command></entry>
+
+ <entry>redirige &man.stdout.4; e &man.stderr.4; in
+ <filename><replaceable>file</replaceable></filename></entry>
+ </row>
+
+ <row>
+ <entry><command>&gt;&gt; <replaceable>file</replaceable>
+ 2&gt;&amp;1</command></entry>
+
+ <entry>appende &man.stdout.4; e &man.stderr.4; in
+ <filename><replaceable>file</replaceable></filename></entry>
+ </row>
+
+ <row>
+ <entry><command>2&gt;&amp;1 |
+ <replaceable>comando</replaceable></command></entry>
+
+ <entry>crea una pipe tra &man.stdout.4;-&man.stderr.4; e il
+ <replaceable>comando</replaceable></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <para>Per redirigere &man.stdout.4; e &man.stderr.4; in due file separati
+ si può fare:</para>
+
+ <screen>$ <userinput><replaceable>comando</replaceable> 1> <replaceable>out_file</replaceable> 2> <replaceable>err_file</replaceable></userinput></screen>
+
+ <para>oppure, data la redirezione di default per &man.stdout.4;:</para>
+
+ <screen>$ <userinput><replaceable>comando</replaceable> > <replaceable>out_file</replaceable> 2> <replaceable>err_file</replaceable></userinput></screen>
+
+ <para>Con la shell Bourne si possono specificare altri descrittori di file
+ (da 3 a 9) e redirigere l'output attraverso questi. Questo può
+ essere fatto con la forma:</para>
+
+ <informaltable frame="none">
+ <tgroup cols="2">
+ <colspec colwidth="1in"/>
+
+ <tbody>
+ <row>
+ <entry><command><replaceable>n</replaceable>&gt;&amp;<replaceable>m</replaceable></command></entry>
+
+ <entry>redirige il descrittore di file
+ <replaceable>n</replaceable> sul descrittore di file
+ <replaceable>m</replaceable></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <para>Questo meccanismo viene utilizzato per mandare &man.stderr.4; nello
+ stesso posto di &man.stdout.4;, <command>2&gt;&amp;1</command>, quando
+ si vuole avere i messaggi di errore e i normali messaggi in un file
+ piuttosto che sul terminale. Se si vuole che solamente i messaggi di
+ errore vadano nel file, si può usare un descrittore di file di
+ supporto, 3. Si redirige prima 3 su 2, quindi 2 su 1 e in fine si
+ redirige 1 su 3.</para>
+
+ <screen>$ <userinput>(<replaceable>comando</replaceable> 3>&2 2>&1 1>&3) > <replaceable>file</replaceable></userinput></screen>
+
+ <para>Questo manda &man.stderr.4; in 1 e &man.stdout.4; in 3 che è
+ rediretto su 2. In questo modo, in effetti, si ribaltano i normali
+ significati dei descrittori di file 1 e 2. Si può sperimentare
+ tutto questo con l'esempio seguente:</para>
+
+ <screen>$ <userinput>(cat <replaceable>file</replaceable> 3>&2 2>&1 1>&3) > <replaceable>errfile</replaceable></userinput></screen>
+
+ <para>Quindi se <filename><replaceable>file</replaceable></filename>
+ è letto, l'informazione è scartata dall'output del
+ comando, ma se <filename><replaceable>file</replaceable></filename> non
+ può essere letto, i messaggi di errore sono messi nel file
+ <filename><replaceable>errfile</replaceable></filename> per usi
+ futuri.</para>
+
+ <para>I descrittori di file che sono stati creati possono essere chiusi
+ con:</para>
+
+ <informaltable frame="none">
+ <tgroup cols="2">
+ <colspec colwidth="1in"/>
+
+ <tbody>
+ <row>
+ <entry><command><replaceable>m</replaceable>&lt;&amp;-</command></entry>
+
+ <entry>chiude un descrittore di file di input</entry>
+ </row>
+
+ <row>
+ <entry><command>&lt;&amp;-</command></entry>
+
+ <entry>chiude &man.stdin.4;</entry>
+ </row>
+
+ <row>
+ <entry><command><replaceable>m</replaceable>&gt;&amp;-</command></entry>
+
+ <entry>chiude un descrittore di file di output</entry>
+ </row>
+
+ <row>
+ <entry><command>&gt;&amp;-</command></entry>
+
+ <entry>chiude &man.stdout.4;</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </sect2>
+ </sect1>
+
+ <sect1 id="special-features-special-comm-simb">
+ <title>Altri speciali simboli di comando</title>
+
+ <para>Oltre ai simboli di redirezione dei file ci sono altri
+ simboli speciali che si possono usare su linea di comando.
+ Alcuni di questi sono:</para>
+
+ <informaltable frame="none">
+ <tgroup cols="2">
+ <colspec colwidth="1.5in"/>
+
+ <tbody>
+ <row>
+ <entry><command>;</command></entry>
+
+ <entry>separatore di comandi</entry>
+ </row>
+
+ <row>
+ <entry><command>&amp;</command></entry>
+
+ <entry>esegue un comando in background</entry>
+ </row>
+
+ <row>
+ <entry><command>&amp;&amp;</command></entry>
+
+ <entry>esegue il comando seguente (a questo simbolo) solamente se il
+ comando precedente (a questo simbolo) è stato completato
+ con successo, esempio:
+ <command>grep <replaceable>stringa file</replaceable> && cat
+ <replaceable>file</replaceable></command></entry>
+ </row>
+
+ <row>
+ <entry><command>||</command></entry>
+
+ <entry>esegue il comando seguente (a questo simbolo) solamente se il
+ comando precedente (a questo simbolo) non è stato
+ completato con successo, esempio:
+ <command>grep <replaceable>stringa file</replaceable> ||
+ echo "Stringa non trovata."</command></entry>
+ </row>
+
+ <row>
+ <entry><command>( )</command></entry>
+
+ <entry>i comandi tra parentesi sono eseguiti in una sotto-shell.
+ L'output della sotto-shell può essere manipolato come
+ specificato nelle precedenti sezioni.</entry>
+ </row>
+
+ <row>
+ <entry><command>' '</command></entry>
+
+ <entry>segni di quoting letterali. All'interno di questi segni di
+ quoting non viene permesso ad alcuni caratteri di assumere
+ significati speciali.</entry>
+ </row>
+
+ <row>
+ <entry><command>\</command></entry>
+
+ <entry>considera il prossimo carattere letteralmente
+ (escape)</entry>
+ </row>
+
+ <row>
+ <entry><command>" "</command></entry>
+
+ <entry>segni di quoting regolari. All'interno di questi segni di
+ quoting sono permesse sostituzioni di variabili e di comando
+ (non disattivano $ e \ all'interno della stringa).</entry>
+ </row>
+
+ <row>
+ <entry><command>`<replaceable>comando</replaceable>`</command></entry>
+
+ <entry>prende l'output del comando e lo sostituisce nell'argomento
+ su linea di comando</entry>
+ </row>
+
+ <row>
+ <entry><command>#</command></entry>
+
+ <entry>ogni cosa che lo segue fino a un newline è un
+ commento</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <para>Inoltre, il carattere \ può essere usato per effettuare un
+ escape sul carattere di newline, in modo tale da continuare un
+ lungo comando su più di una linea fisica di testo.</para>
+ </sect1>
+
+ <sect1 id="special-features-wildcard">
+ <title>Meta caratteri</title>
+
+ <para>La shell e alcuni programmi di manipolazione testo permettono i
+ <emphasis>meta-caratteri</emphasis>, chiamati anche
+ <emphasis>wild card</emphasis>, i quali vengono rimpiazzati dai
+ corrispondenti schemi (pattern). Per i nomi di file questi
+ <emphasis>meta-caratteri</emphasis> e i loro significati sono:</para>
+
+ <informaltable frame="none">
+ <tgroup cols="2">
+ <colspec colwidth="1.5in"/>
+
+ <tbody>
+ <row>
+ <entry><emphasis>?</emphasis></entry>
+
+ <entry>indica un singolo carattere alla posizione
+ indicata</entry>
+ </row>
+
+ <row>
+ <entry><emphasis>*</emphasis></entry>
+
+ <entry>indica una stringa di zero o più
+ caratteri</entry>
+ </row>
+
+ <row>
+ <entry><emphasis>[abc...]</emphasis></entry>
+
+ <entry>indica un carattere tra quelli racchiusi</entry>
+ </row>
+
+ <row>
+ <entry><emphasis>[a-e]</emphasis></entry>
+
+ <entry>indica un carattere tra quelli nel range a, b, c, d,
+ e</entry>
+ </row>
+
+ <row>
+ <entry><emphasis>[!def]</emphasis></entry>
+
+ <entry>indica un carattere tra quelli non inclusi in parentesi,
+ solamente &man.sh.1;</entry>
+ </row>
+
+ <row>
+ <entry><emphasis>{abc,bcd,cde}</emphasis></entry>
+
+ <entry>indica un set di caratteri tra quelli inclusi in parentesi,
+ separati da una virgola (,) (niente spazi), solamente
+ &man.csh.1;</entry>
+ </row>
+
+ <row>
+ <entry><emphasis>~</emphasis></entry>
+
+ <entry>indica la directory home dell'utente corrente, solamente
+ &man.csh.1;</entry>
+ </row>
+
+ <row>
+ <entry><emphasis>~<replaceable>user</replaceable></emphasis></entry>
+
+ <entry>indica la directory home dell'utente specificato, solamente
+ &man.csh.1;</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </sect1>
+</chapter>