Newer
Older
cours-unix-shell / UnixShell_cours2018 / commandeShell.fre.html
<html>
  <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <link REL="STYLESHEET" TYPE="text/css" TITLE="Style DILIB" HREF="../../dilib.css">
    <style type="text/css">
.remarque, .exemple { font-size: small; }
    </style>
    <title>Commandes diverses - Shell - UNIX</title>
    <link rel="copyright" href="http://www.inist.fr/"><link rel="author" href="http://dilib.inist.fr/membres.html"><link rel="chapter" href="caracteristiques.fre.html" title="UNIX"><link rel="chapter" href="X.fre.html" title="X Window"><link rel="chapter" href="redirPipes.fre.html" title="Rappels"><link rel="chapter" href="newCommandsUser.fre.html" title="Commandes UNIX"><link rel="chapter" href="shellVars.fre.html" title="Shell"><link rel="chapter" href="sed.fre.html" title="Sed"><link rel="chapter" href="make.fre.html" title="Make"><link rel="index" href="http://dilib.inist.fr/dilib/v04Main/IndexSite/Server/FR.resource.index.html"><link rel="top" title="Accueil de DILIB" href="http://dilib.inist.fr/dilib/v04Main/"><link rel="alternate" title="English version" href="commandeShell.eng.html"><link rel="up" href="index.fre.html" title="Tutorial UNIX / Shell">
    <link rel="section" href="shellVars.fre.html" title="Variables d'environnement"><link rel="section" href="shellScript.fre.html" title="Scripts"><link rel="section" href="paramShell.fre.html" title="Param&egrave;tres"><link rel="section" href="testShell.fre.html" title="Tests"><link rel="section" href="structureShell.fre.html" title="Structures de contr&ocirc;le"><link rel="section" href="commandeShell.fre.html" title="Commandes diverses"><link rel="section" href="tpShell.fre.html" title="Travaux Pratiques">
    <link rel="first" href="caracteristiques.fre.html" title="Caract&eacute;ristiques d'UNIX">
    <link rel="previous" href="structureShell.fre.html" title="Structures de contr&ocirc;le">
    <link rel="next" href="tpShell.fre.html" title="Travaux Pratiques">
    <link rel="last" href="tpShell.fre.html" title="Travaux Pratiques">
  </head>

  <body>
    <h1>Commandes diverses - Shell - UNIX</h1>

    <div id="navcontainer">
      <ul id="navlist">
	<li><a href="caracteristiques.fre.html">UNIX</a>
	</li>
	<li><a href="redirPipes.fre.html">Bases</a>
	</li>
	<li><a href="newCommandsUser.fre.html">Commandes</a>
	</li>
	<li><a>Shell</a>
	  <ul id="subnavlist">
	    <li><a href="shellVars.fre.html">Variables d'environnement</a></li>
	    <li><a href="shellScript.fre.html">Scripts</a></li>
	    <li><a href="paramShell.fre.html">Param&egrave;tres</a></li>
	    <li><a href="testShell.fre.html">Tests</a></li>
	    <li><a href="structureShell.fre.html">Structures de contr&ocirc;le</a></li>
	    <li><a href="commandeShell.fre.html" id="subcurrent">Commandes</a></li>
	    <li><a href="tpShell.fre.html">TP</a></li>
	  </ul>
	</li>
	<li><a href="sed.fre.html">Sed</a>
	</li>
	<li><a href="make.fre.html">Make</a>
	</li>
      </ul>
    </div>
    
    <div class="content">
    <h2>Commandes</h2>

    <table border="1" class="var">
      <tbody>
	<tr>
	  
	  <td><b>#</b></td>
	  <td>
	    commentaires (mais <code>#!/bin/sh</code> en d&eacute;but de
	    fichier est le shebang)
	  </td>
	</tr>
	<tr>
	  
	  <td><b>(</b> commande <b>)</b></td>
	  <td>ex&eacute;cute la commande dans un sous-shell</td>
	</tr>
	<tr>
	  
	  <td><b>read</b> a</td>
	  <td>lecture d'une entr&eacute;e pendant l'ex&eacute;cution d'un script</td>
	</tr>
	<tr>
	  
	  <td><b>exit</b> num</td>
	  <td>renvoie le statut du script au shell appelant</td>
	</tr>
	<tr>
	  
	  <td><b>.</b> script</td>
	  <td>inclusion et ex&eacute;cution du script dans le shell courant</td>
	</tr>
	<tr>
	  
	  <td><b>exec</b> script</td>
	  <td>ex&eacute;cute le script dans un nouveau shell</td>
	</tr>
	<tr>
	  <td>cmd1 <b>||</b> cmd2</td>
	  <td>
	    s&eacute;parateur conditionnel (cmd2 est ex&eacute;cut&eacute;e m&ecirc;me si cmd1 ne
	    s'est pas ex&eacute;cut&eacute;e correctement)
	  </td>
	</tr>
	<tr>
	  
	  <td><b>set</b></td>
	  <td>
	    liste de toutes les variables<br>
	    positionne les param&egrave;tres <code>$i</code> (<code>set a b
	    c</code> positionne <code>$1</code> &agrave; <code>a</code>,
	    <code>$2</code> &agrave; <code>b</code> et <code>$3</code> &agrave;
	    <code>c</code>).
	  </td>
	</tr>
	<tr>
	  
	  <td><b>unset</b> var</td>
	  <td>remise &agrave; z&eacute;ro de la variable <code>var</code></td>
	</tr>
	<tr>
	  
	  <td><b>type</b> cmde</td>
	  <td>indique la nature (et la localisaton) d'une commande</td>
	</tr>
	<tr>
	  
	  <td><b>alias</b> al='cmd'</td>
	  <td>
	    cr&eacute;e une commande <code>al</code> &eacute;quivalente &agrave; la
	    commande <code>cmd</code> (qui peut &ecirc;tre complexe)
	  </td>
	</tr>
	<tr>
	  
	  <td><b>touch</b> fichier</td>
	  <td>
	    change la date de derni&egrave;re modification du fichier. Si le
	    fichier n'existe pas, cr&eacute;e un fichier vide.
	  </td>
	</tr>
      </tbody>
    </table>

    <h2>expr</h2>
    <table border="1" class="var">
      <tbody>
	<tr>
	  
	  <td><b>expr</b></td>
	  <td>
	    ex&eacute;cute des op&eacute;rations arithm&eacute;tiques (<code>op</code> peut
	    valoir +, -, \*, /, %, =, \&gt;, \&lt;, \&gt;=, \&lt;=,
	    !=)
	  </td>
	</tr>
      </tbody>
    </table>
    <p>
      L'expression est une commande, donc pour affecter une op&eacute;ration
      &agrave; une variable, il faut forcer son ex&eacute;cution&nbsp; avec 
      des antiquotes (AltGr 7) :
    </p>
    <pre>a=`expr $b + $c`</pre>
    </div>
    <hr>
    <address><a href="mailto:philippe.houdry@inist.fr">Philippe.Houdry@inist.fr</a></address>
  </body>
</html>