td_-_expressions_regulieres
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
td_-_expressions_regulieres [2019/01/22 15:56] – gilles | td_-_expressions_regulieres [2022/03/15 15:05] (Version actuelle) – [Lister des fichiers] gilles | ||
---|---|---|---|
Ligne 58: | Ligne 58: | ||
^ [2] | '' | ^ [2] | '' | ||
^ [2] | '' | ^ [2] | '' | ||
- | ^ $[1]$ | \verb|i\| {\em texte} | insertion du {\em texte} sur la sortie standard | + | ^ [1] | '' |
- | ^ $[2]$ | \verb|p| | \' | + | ^ [2] | '' |
- | \ & q & terminaison | + | ^ | q | terminaison |
- | ^ $[2]$ | \verb|r| {\em file} | \' | + | ^ [2] | '' |
- | ^ $[2]$ | \verb|s/regexpr/| \verb|chaine/ind| | substitution d'un motif \`a un autre d\' | + | ^ [2] | '' |
- | ^ $[2]$ | \verb|w| {\em file} | \' | + | ^ [2] | '' |
- | ^ $[2]$ | | + | ^ [2] | |
- | ^ $[2]$ | \verb|!| {\em commande} | ex\' | + | ^ [2] | '' |
- | ^ $[2]$ | \verb|=| | Donne le num\' | + | ^ [2] | '' |
+ | ==== Un peu d' | ||
+ | * Que fait la commande suivante ? | ||
- | \section{Un peu d'entra\^inement} | + | <code bash> |
+ | sed -n '/^[0-9]\+$/ | ||
+ | </ | ||
- | Que fait la commande suivante | + | * Donner le résultat de la commande suivante |
- | \begin{verbatim} | + | <code bash> |
- | sed -n '/ | + | echo aabbabbaab | sed $motif |
- | \end{verbatim} | + | </code> |
- | \noindent Donner le r\' | + | <code bash> |
- | \begin{verbatim}echo ``aabbabbaab'' | + | motif=' |
- | pour : | + | motif=' |
- | \begin{verbatim}motif=' | + | motif=' |
- | \begin{verbatim}motif=' | + | motif=' |
- | \begin{verbatim}motif=' | + | motif=' |
- | \begin{verbatim}motif=' | + | </ |
- | \begin{verbatim}motif=' | + | |
- | \noindent donner | + | * Donner |
- | \begin{verbatim}echo ``ejkf fed 158e fd'' | + | |
- | \begin{verbatim}echo ``ejkf fed 158e fd'' | + | < |
+ | | ||
+ | echo "ejkf fed 158e fd" | ||
+ | </ | ||
- | \section{Head} | ||
- | R\' | + | ==== HEAD ==== |
- | \section{Html} | + | Réécrire la commande '' |
- | \' | + | ==== HTML ==== |
- | %\section{To Upper} | + | Ecrire |
- | %\noindent | + | |
- | \section{Cut} | + | ==== A partir d'un fichier ... ==== |
- | \'Ecrire une commande qui extrait la premi\`ere colonne du fichier | + | On suppose le fichier suivant '' |
- | D\' | + | < |
+ | Marcel: | ||
+ | Ghislaine: | ||
+ | Raymond: | ||
+ | </ | ||
- | \section{Date} | + | * Ecrire une commande qui transforme les caractéres du fichier '' |
+ | * Ecrire une commande qui extrait la première colonne du fichier '' | ||
+ | * Déplacer la colonne de gauche en dernière position. | ||
- | La fonction date renvoie un r\' | + | ==== DATE ==== |
- | \begin{verbatim} | + | La fonction date renvoie un résultat de la forme suivante |
- | jeu jan 26 17:26:47 CET 2019 | + | |
- | \end{verbatim} | + | |
- | \' | + | < |
+ | jeu jan 26 17:26:47 CET 2019 | ||
+ | </ | ||
- | \begin{verbatim} | + | Ecrivez une commande, en utilisant '' |
- | Nous sommes | + | |
- | \end{verbatim} | + | |
- | \' | + | < |
+ | Nous sommes | ||
+ | </ | ||
- | \section{Un peu de grep} | + | Ecrire la commande '' |
- | Que font les commandes suivantes ([ ] contient un espace et une tabulation) : | + | ==== Un peu de GREP ==== |
- | \begin{verbatim} | + | |
- | grep -c ' | + | |
- | grep -c ' | + | |
- | grep -c ' | + | |
- | grep -n -v ' | + | |
- | \end{verbatim} | + | |
- | \section{Update} | + | Que font les commandes suivantes ? ('' |
- | \'Ecrivez une commande qui liste les noms de r\'epertoires commen{\c c}ant par la lettre a. | + | <code bash> |
+ | grep -E -c '^[ ]*$' | ||
+ | grep -E -c ' | ||
+ | grep -E -c ' | ||
+ | grep -E -n -v ' | ||
+ | </ | ||
- | \bigskip | + | ==== Lister des fichiers ==== |
- | \' | + | La commande ''ls -l'' produit la sortie suivante |
- | \begin{verbatim} | + | < |
- | fichier poly-se.aux modifie ce jour a 17:00 | + | drwxr-xr-x 4 gilles |
- | fichier poly-se.dvi modifie ce jour a 17:24 | + | drwxr-xr-x 2 gilles |
- | fichier poly-se.log modifie ce jour a 17:56 | + | -rw-r--r-- |
- | fichier poly-se.ps modifie ce jour a 17:01 | + | -rw-r--r-- |
- | fichier poly-se.toc modifie ce jour a 17:56 | + | -rw-r--r-- |
- | fichier td_sed.tex modifie ce jour a 17:56 | + | </ |
- | \end{verbatim} | + | |
- | \section{Liste des extensions} | + | * Modifiez cette commande afin d' |
- | \begin{verbatim} | + | < |
- | $ls | + | dir-1 modifie a 11:41 |
- | abc ab.o ab.tar.gz | + | dir-2 modifie a 14:41 |
- | \end{verbatim} | + | file-1 modifie a 22:39 |
+ | file-2 modifie a 08:18 | ||
+ | mon-script-exemple.sh modifie a 07:03 | ||
+ | </ | ||
+ | |||
+ | ==== Liste des extensions ==== | ||
+ | |||
+ | <code bash> | ||
+ | | ||
+ | abc ab.o ab.tar.gz | ||
+ | </ | ||
Ecrivez la commande permettant d' | Ecrivez la commande permettant d' | ||
- | \begin{verbatim} | + | <code bash> |
- | .c | + | .c |
- | .gz | + | .gz |
- | .o | + | .o |
- | .zip | + | .zip |
- | \end{verbatim} | + | </ |
td_-_expressions_regulieres.1548172574.txt.gz · Dernière modification : 2019/01/22 15:56 de gilles