notebook/IT/linux/shell.md
vincent efbd8ba596
All checks were successful
continuous-integration/drone/push Build is passing
finish markdown linting
2021-04-20 23:13:14 +02:00

891 B

shell

tips

  • setter IFS au retour chariot

IFS=$'\n'

boucle

for var in $variable
do
     commande
done

if

if [ test ]; then
        echo "C'est vrai"
else
    echo "c'est faux"
fi

test

string

test def
$a = j$b egale
$a != $b different
-z $a est vide
-n $a est non vide

int

test def
$a -eq $b egale
$a -ne $b non egale
$a -lt $b <
$a -le $b <=
$a -gt $b >
$a -ge $b >=

file

test def
-e $a exist
-d $a is directory
-f $a is file
-L $a is symbolic link
-r -w -x test permition
$a -nt $b $a plus récent
$a -ot $b $a plus vieux

Supprimer les Dossiers contenant 1 élement

IFS=$'\n';for i in $(ls) do               ✔  10022  18:29:32   
        if [ $(ls $i|wc|awk '{print $1}') = 1 ]
then
rm -r $i
fi