User Tools

Site Tools


bash

This is an old revision of the document!


#!/bin/bash

Stocker le résultat d'une commande

var=$(ls /);
echo $var;

Fonctions

function bonjour { # ne pas oublier espace avant {
        echo 'bonjour'
}

bonjour # appel de la fonction

Fonction paramètres

function ecrire {
        echo "$1 $2"
}
ecrire 'toto' 'tata'

Tableau

tab[0]="toto"
tab[1]="tata"

echo $tab[1]

for mot in ${tab[*]}
do
echo $mot;
done

Arguments de script

echo $1 #premier argument
echo $2
echo $* #tous les arguments

Afficher la sortie de la dernière commande passée
<code>
echo $_

</code>

bash.1707751512.txt.gz · Last modified: 2024/02/12 15:25 by 195.221.243.132 · Currently locked by: 216.73.217.114