<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ètres"><link rel="section" href="testShell.fre.html" title="Tests"><link rel="section" href="structureShell.fre.html" title="Structures de contrô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éristiques d'UNIX"> <link rel="previous" href="structureShell.fre.html" title="Structures de contrô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ètres</a></li> <li><a href="testShell.fre.html">Tests</a></li> <li><a href="structureShell.fre.html">Structures de contrô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ébut de fichier est le shebang) </td> </tr> <tr> <td><b>(</b> commande <b>)</b></td> <td>exécute la commande dans un sous-shell</td> </tr> <tr> <td><b>read</b> a</td> <td>lecture d'une entrée pendant l'exé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écution du script dans le shell courant</td> </tr> <tr> <td><b>exec</b> script</td> <td>exécute le script dans un nouveau shell</td> </tr> <tr> <td>cmd1 <b>||</b> cmd2</td> <td> séparateur conditionnel (cmd2 est exécutée même si cmd1 ne s'est pas exécutée correctement) </td> </tr> <tr> <td><b>set</b></td> <td> liste de toutes les variables<br> positionne les paramètres <code>$i</code> (<code>set a b c</code> positionne <code>$1</code> à <code>a</code>, <code>$2</code> à <code>b</code> et <code>$3</code> à <code>c</code>). </td> </tr> <tr> <td><b>unset</b> var</td> <td>remise à zé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ée une commande <code>al</code> équivalente à la commande <code>cmd</code> (qui peut être complexe) </td> </tr> <tr> <td><b>touch</b> fichier</td> <td> change la date de dernière modification du fichier. Si le fichier n'existe pas, cré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écute des opérations arithmétiques (<code>op</code> peut valoir +, -, \*, /, %, =, \>, \<, \>=, \<=, !=) </td> </tr> </tbody> </table> <p> L'expression est une commande, donc pour affecter une opération à une variable, il faut forcer son exécution 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>