\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{TME520 (TME520)} \pdfinfo{ /Title (awk.pdf) /Creator (Cheatography) /Author (TME520 (TME520)) /Subject (awk Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{545454} \definecolor{LightBackground}{HTML}{F4F4F4} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{awk Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{TME520 (TME520)} via \textcolor{DarkBackground}{\uline{cheatography.com/20978/cs/3896/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}TME520 (TME520) \\ \uline{cheatography.com/tme520} \\ \uline{\seqsplit{tme520}.com} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 19th April, 2015.\\ Updated 12th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Fonctionnement général}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\emph{awk}} lit sur l'entrée (fichier ou saisie clavier) ligne par ligne, puis sélectionne les lignes à traiter à l'aide d'expressions rationnelles. Chaque ligne sélectionnée est découpée en champs selon le séparateur d'entrée désigné par le symbole FS (caractère espace ou tabulation). Puis les différents champs sont mis à disposition dans des variables : \$1 (1er champ), \$2 (2ème champ), \$3 (3ème champ), …, \$NF (dernier champ).% Row Count 10 (+ 10) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Options et paramètres}} \tn % Row 0 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{-F {\emph{fs}}}} {\emph{ou}} {\bf{-{}-field-sepearator {\emph{fs}}}} & Utilise {\emph{fs}} comme séparateur de champs. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \{\{nobreak\}\}{\bf{-v {\emph{var}}={\emph{val}}}} {\emph{ou}} {\bf{-{}-assign {\emph{var}}={\emph{val}}}} & Assigne la valeur {\emph{val}} à {\emph{var}}. \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{-f {\emph{program-file}}}} {\emph{ou}} {\bf{-{}-file {\emph{program-file}}}} & Charge et exécute {\emph{program-file}}. \tn % Row Count 10 (+ 4) % Row 3 \SetRowColor{white} \{\{nobreak\}\}{\bf{-mf {\emph{NNN}}}} {\emph{ou}} {\bf{-mr {\emph{NNN}}}} & {\emph{mr}} pour {\emph{maximum number of records}} (nbr max d'enregistrements) et {\emph{mf}} pour {\emph{maximum number of fields}} (nbr max de champs). \tn % Row Count 17 (+ 7) % Row 4 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{-W {\emph{compat}}}} {\emph{ou}} {\bf{-W {\emph{traditional}}}} {\emph{ou}} {\bf{-{}-compat-{}-traditional}} & Permet une compatibilité entre les différentes variantes d'AWK (awk, nawk, gawk). \tn % Row Count 22 (+ 5) % Row 5 \SetRowColor{white} \{\{nobreak\}\}{\bf{-W dump-variables{[}=fichier{]}}} {\emph{ou}} {\bf{-{}-dump-variables{[}=fichier{]}}} & Affiche un récapitulatif trié des variables globales, leurs types et leurs valeurs. \tn % Row Count 27 (+ 5) % Row 6 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{-W help}} {\emph{ou}} {\bf{-W usage}} {\emph{ou}} {\bf{-{}-help}} {\emph{ou}} {\bf{-{}-usage}} & Affiche l'aide. \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Options et paramètres (cont)}} \tn % Row 7 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{-W version}} {\emph{ou}} {\bf{-{}-version}} & Affiche la version. \tn % Row Count 3 (+ 3) % Row 8 \SetRowColor{white} \{\{nobreak\}\}{\bf{-{}-}} & Marque la fin des options. \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Entrées/sorties}} \tn % Row 0 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{close({\emph{fichier}} {[}, {\emph{méthode}}{]})}} & Ferme un fichier, un {\emph{pipe}} ou un traitement déporté. Le paramètre optionnel {\emph{méthode}} n'est à utiliser que lors de la fermeture d'un {\emph{pipe}} bidirectionnel vers un traitement déporté (valeurs possibles : "to" ou "from"). \tn % Row Count 12 (+ 12) % Row 1 \SetRowColor{white} \{\{nobreak\}\}{\bf{getline}} & Charge la dernière saisie dans \$0 ; NF, NR et FNR sont également initialisés. Retourne 0 une fois atteinte la fin du fichier (EOF) ou 1 en cas d'erreur. Si erreur il y a, ERRNO contient une description du problème. \tn % Row Count 23 (+ 11) % Row 2 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{getline \textless{}{\emph{fichier}}}} & Renseigne \$0 avec le contenu de l'enregistrement ({\emph{record}}) suivant ; initialise NF. \tn % Row Count 28 (+ 5) % Row 3 \SetRowColor{white} \{\{nobreak\}\}{\bf{getline {\emph{var}}}} & Renseigne {\emph{var}} avec le contenu de la saisie ({\emph{input record}}) suivante ; initialise NF ainsi que FNR. \tn % Row Count 34 (+ 6) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Entrées/sorties (cont)}} \tn % Row 4 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{getline {\emph{var}} \textless{}{\emph{fichier}}}} & Renseigne {\emph{var}} avec le contenu de l'enregistrement ({\emph{record}}) suivant issu de {\emph{fichier}}. \tn % Row Count 5 (+ 5) % Row 5 \SetRowColor{white} \{\{nobreak\}\}{\bf{{\emph{commande}} | getline {[}{\emph{var}}{]}}} & Exécute la {\emph{commande}} et envoie la sortie soit vers \$0, soit vers {\emph{var}}. \tn % Row Count 9 (+ 4) % Row 6 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{{\emph{commande}} |\& getline {[}{\emph{var}}{]}}} & Exécute {\emph{commande}} en qualité de traitement déporté. \tn % Row Count 12 (+ 3) % Row 7 \SetRowColor{white} \{\{nobreak\}\}{\bf{next}} & Interrompt le traitement de l'enregistrement ({\emph{record}}) courant, puis passe au suivant. \tn % Row Count 17 (+ 5) % Row 8 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{nextfile}} & Interrompt le traitement du fichier en cours, puis passe au suivant. FILENAME et ARGIND sont mis à jour, FNR repasse à 1. \tn % Row Count 24 (+ 7) % Row 9 \SetRowColor{white} \{\{nobreak\}\}{\bf{print}} & Affiche l'enregistrement ({\emph{record}}) en cours. La chaîne se termine par le contenu de la variable OFS. \tn % Row Count 30 (+ 6) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Entrées/sorties (cont)}} \tn % Row 10 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{print {\emph{expressions}}}} & Affiche les éléments passés en paramètre, tous séparés par la valeur définie dans OFS. La chaîne de sortie se termine par la valeur contenue dans ORS. \tn % Row Count 8 (+ 8) % Row 11 \SetRowColor{white} \{\{nobreak\}\}{\bf{print {\emph{expressions}} \textgreater{}{\emph{fichier}}}} & Insère dans {\emph{fichier}} les éléments passés en paramètre, tous séparés par la valeur définie dans OFS. La chaîne de sortie se termine par la valeur contenue dans ORS. \tn % Row Count 17 (+ 9) % Row 12 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{printf {\emph{format}}, {\emph{expressions}}}} & Affichage formaté, à la manière du {\emph{printf}} du C. \tn % Row Count 20 (+ 3) % Row 13 \SetRowColor{white} \{\{nobreak\}\}{\bf{printf {\emph{format}}, {\emph{expressions}} \textgreater{}{\emph{fichier}}}} & Même chose qu'au-dessus, mais dans un fichier. \tn % Row Count 23 (+ 3) % Row 14 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{system({\emph{ligne de commande}})}} & La {\emph{commande}} est exécutée et son code de sortie récupéré. \tn % Row Count 27 (+ 4) % Row 15 \SetRowColor{white} \{\{nobreak\}\}{\bf{fflush({[}{\emph{fichier}}{]})}} & Purge les caches associés avec le {\emph{fichier}}. Si ce dernier n'existe pas, c'est {\emph{stdout}} qui se trouve purgé. Si le paramètre {\emph{fichier}} est à {\emph{null}}, tous les caches de fichiers et de {\emph{pipes}} sont alors purgés. \tn % Row Count 38 (+ 11) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Entrées/sorties (cont)}} \tn % Row 16 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{print ... \textgreater{}\textgreater{} {\emph{fichier}}}} & Ajout de données à la fin d'un {\emph{fichier}}. \tn % Row Count 3 (+ 3) % Row 17 \SetRowColor{white} \{\{nobreak\}\}{\bf{print ... | {\emph{commande}}}} & Envoie la sortie d'une {\emph{commande}} dans un {\emph{pipe}}. \tn % Row Count 6 (+ 3) % Row 18 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{print ... |\& {\emph{commande}}}} & Envoie des données à un traitement déporté. \tn % Row Count 9 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Actions pré-traitement et post-traitement}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{BEGIN \{ Actions\} \newline % Row Count 1 (+ 1) \{ACTION\} \# Actions qui seront exécutées sur chaque ligne \newline % Row Count 3 (+ 2) END \{ Actions \} \newline % Row Count 4 (+ 1) \# les lignes de commentaires commencent par un dièse.% Row Count 6 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{Les actions suivant la balise BEGIN sont exécutées avant que le traitement des données fournies en entrée ne commence, tandis que les actions derrière END sont exécutées une fois que toutes les lignes ont été traitées.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.4623 cm} x{8.8077 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Fonctions relatives au temps}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{systime()}} & Retourne le nombre de secondes écoulées depuis l'Epoch (1970-01-01 00:00:00 UTC). \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} {\bf{mktime({\emph{datespec}})}} & Transforme {\emph{datespec}} (de la forme YYYY MM DD HH MM SS{[} DST{]}) en nombre de secondes écoulées depuis l'Epoch (1970-01-01 00:00:00 UTC). \tn % Row Count 12 (+ 7) % Row 2 \SetRowColor{LightBackground} {\bf{strftime({[}{\emph{format}} {[}, timestamp{]}{]})}} & Formate {\emph{timestamp}} sur la base de ce qui est fourni dans {\emph{format}}. {\emph{timestamp}} est un nombre de secondes écoulées depuis l'Epoch tel que retourné par {\emph{systime()}}. Si {\emph{timestamp}} n'est pas renseigné, l'heure courante est utilisée. \tn % Row Count 24 (+ 12) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{4.6629 cm} x{12.6071 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Variables}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{FS}} & Séparateur de champs en entrée. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{OFS}} & Séparateur de champs en sortie. \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{RS}} & Séparateur de lignes en entrée. \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} {\bf{ORS}} & Séparateur de lignes en sortie. \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{NR}} & Nombre de lignes. \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} {\bf{NF}} & Nombre de champs. \tn % Row Count 10 (+ 1) % Row 6 \SetRowColor{LightBackground} {\bf{FILENAME}} & Nom du fichier passé en paramètre. \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} {\bf{FNR}} & Nombre de lignes dans le fichier courant. \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{\$0}} & Toute la ligne. \tn % Row Count 15 (+ 1) % Row 9 \SetRowColor{white} {\bf{\$1, \$2...\$n}} & Champs de 1 à {\emph{n}}. \tn % Row Count 17 (+ 2) % Row 10 \SetRowColor{LightBackground} {\bf{ARGC}} & Nombre de paramètres sur la ligne de commande. \tn % Row Count 19 (+ 2) % Row 11 \SetRowColor{white} {\bf{ARGV}} & Tableau contenant les paramètres passés sur la ligne de commandes. Indexé de 0 à ARGC - 1. \tn % Row Count 23 (+ 4) % Row 12 \SetRowColor{LightBackground} {\bf{ARGIND}} & Indique quel fichier listé dans ARGV est en cours de traitement. \tn % Row Count 26 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Notions-clef}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{- {\emph{awk}} voit le texte sous la forme de lignes et de champs, \newline % Row Count 2 (+ 2) - {\emph{awk}} supporte l'usage de conditions, de boucles et de variables, \newline % Row Count 4 (+ 2) - {\emph{awk}} peut traiter des chaînes de caractères et des chiffres, \newline % Row Count 6 (+ 2) - {\emph{awk}} peut générer des rapports formatés.% Row Count 7 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.2896 cm} x{8.9804 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Opérateurs}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{\&\& || !}} & Opérateurs logiques (ET, OU, NON). \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{\textless{} \textless{}= == != \textgreater{}= \textgreater{} \textasciitilde{} !\textasciitilde{}}} & Opérateurs de comparaison. \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{6.5626 cm} x{10.7074 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Mathématiques}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{atan2({\emph{y}}, {\emph{x}})}} & Retourne l'arc tangente de y/x en radians. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{cos({\emph{x}})}} & Retourne le cosinus de {\emph{x}}, en radians. \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{exp({\emph{z}})}} & Retourne l'exponentielle de {\emph{z}}. \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} {\bf{int({\emph{f}})}} & Retourne la part entière de {\emph{f}}. \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{log({\emph{e}})}} & Fonction logarithmique. \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} {\bf{rand()}} & Retourne un nombre réel aléatoire N compris entre 0 et 1 où 0 \textless{}= N \textless{} 1. \tn % Row Count 13 (+ 4) % Row 6 \SetRowColor{LightBackground} {\bf{sin({\emph{x}})}} & Retourne la sinusoïdale de {\emph{x}}, en radians. \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} {\bf{sqrt({\emph{x}})}} & Retourne la racine carrée de {\emph{x}}. \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{srand({[}{\emph{expression}}{]})}} & Génère un nombre aléatoire sur la base d'{\emph{expression}}. Si {\emph{expression}} n'est pas renseigné, la date est utilisée. \tn % Row Count 22 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Traitements sur les chaînes}} \tn % Row 0 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{asort({\emph{s}} {[}, {\emph{d}}{]})}} & Retourne le nombre d'éléments présents dans le tableau {\emph{s}}. Le contenu de {\emph{s}} est trié, puis réindexé en partant de 1. Si le tableau destination optionnel {\emph{d}} est spécifié, alors {\emph{s}} est dupliqué dans {\emph{d}}, puis le traitement s'effectue sur {\emph{d}}, laissant {\emph{s}} inchangé. \tn % Row Count 14 (+ 14) % Row 1 \SetRowColor{white} \{\{nobreak\}\}{\bf{asorti({\emph{s}} {[}, {\emph{d}}{]})}} & Même chose que {\emph{asort()}} à ceci près que ce sont les indices du tableau et non les valeurs qu'il contient qui sont utilisées pour le tri. \tn % Row Count 22 (+ 8) % Row 2 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{gensub({\emph{r}}, {\emph{s}}, {\emph{h}} {[}, {\emph{t}}{]})}} & Cherche les occurrences de la regex {\emph{r}} dans {\emph{t}}. Si {\emph{h}} est une chaîne commençant par g ou G, alors toutes les occurrences de {\emph{r}} sont remplacées par {\emph{s}}. Sinon, {\emph{h}} est necessairement un chiffre indiquant quelle occurrence de {\emph{r}} remplacer. Si {\emph{t}} n'est pas fourni, \$0 est alors utilisé. Cette fonction, au contraire de {\emph{sub()}} et {\emph{gsub()}}, retourne la chaîne modifiée en résultat, laissant la chaîne d'origine inchangée. \tn % Row Count 44 (+ 22) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Traitements sur les chaînes (cont)}} \tn % Row 3 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{gsub({\emph{r}}, {\emph{s}} {[}, {\emph{t}}{]})}} & Remplace toutes les occurrences de la regex {\emph{r}} au sein de la chaîne {\emph{t}} par {\emph{s}}, puis retourne le nombre de changements opérés. Si {\emph{t}} n'est pas renseigné, \$0 est utilisé. \tn % Row Count 9 (+ 9) % Row 4 \SetRowColor{white} \{\{nobreak\}\}{\bf{index({\emph{s}}, {\emph{t}})}} & Retourne la position de {\emph{t}} dans {\emph{s}} ou 0 si {\emph{t}} n'est pas trouvé. \tn % Row Count 13 (+ 4) % Row 5 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{length({[}{\emph{s}}{]})}} & Retourne la taille de la chaîne {\emph{s}}. \tn % Row Count 15 (+ 2) % Row 6 \SetRowColor{white} \{\{nobreak\}\}{\bf{match({\emph{s}}, {\emph{r}} {[}, {\emph{a}}{]})}} & Retourne la position de la regex {\emph{r}} au sein de {\emph{s}}. RSTART et RLENGTH sont initialisées. \tn % Row Count 20 (+ 5) % Row 7 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{split({\emph{s}}, {\emph{a}} {[}, {\emph{r}}{]})}} & Découpe la chaîne {\emph{s}} sur la base de la regex {\emph{r}} et stocke les sections résultantes dans le tableau {\emph{a}}. Le nombre de champs ({\emph{fields}}) est retourné. Si {\emph{r}} n'est pas fourni, FS est utilisé. Notez que {\emph{a}} est vidé avant le début du traitement. \tn % Row Count 33 (+ 13) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Traitements sur les chaînes (cont)}} \tn % Row 8 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{sprintf({\emph{format}}, {\emph{expressions}})}} & Affichage formaté, à la manière de {\emph{printf}} en C. \tn % Row Count 3 (+ 3) % Row 9 \SetRowColor{white} \{\{nobreak\}\}{\bf{strtonum({\emph{chaîne}})}} & Transforme une chaîne en nombre. Si la chaîne commence par 0, elle est traitée comme une valeur octale. Si elle commence par 0x ou 0X, elle est traitée comme une valeur hexadécimale. \tn % Row Count 13 (+ 10) % Row 10 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{sub({\emph{r}}, {\emph{s}} {[}, {\emph{t}}{]})}} & Remplace la 1ère occurrence de la regex {\emph{r}} au sein de la chaîne {\emph{t}} par {\emph{s}}, puis retourne le nombre de changements opérés. Si {\emph{t}} n'est pas renseigné, \$0 est utilisé. \tn % Row Count 22 (+ 9) % Row 11 \SetRowColor{white} \{\{nobreak\}\}{\bf{substr({\emph{s}}, {\emph{i}} {[}, {\emph{n}}{]})}} & Collecte le contenu de {\emph{s}} à partir du point {\emph{i}}. Si {\emph{n}} (balise de fin) n'est pas fourni, alors on récupère le reste de {\emph{s}}. \tn % Row Count 29 (+ 7) % Row 12 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{tolower({\emph{chaîne}})}} & Transforme les majuscules en minuscules. \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Traitements sur les chaînes (cont)}} \tn % Row 13 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{toupper({\emph{chaîne}})}} & Transforme les minuscules en majuscules. \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.5988 cm} x{9.6712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Manipulation d'éléments binaires}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{and({\emph{v1}}, {\emph{v2}})}} & ET logique sur {\emph{v1}} et {\emph{v2}}. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{compl({\emph{vx}})}} & Retourne le complément bit-à-bit de {\emph{vx}}. \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{lshift({\emph{valeur}}, {\emph{compteur}})}} & Décale {\emph{valeur}} de {\emph{compteur}} bits vers la gauche. \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} {\bf{or({\emph{v1}}, {\emph{v2}})}} & OU logique sur {\emph{v1}} et {\emph{v2}}. \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{rshift({\emph{valeur}}, {\emph{compteur}})}} & Décale {\emph{valeur}} de {\emph{compteur}} bits vers la droite. \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} {\bf{xor({\emph{v1}}, {\emph{v2}})}} & OU EXCLUSIF sur {\emph{v1}} et {\emph{v2}}. \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \end{document}