jeudi 26 mars 2020

Why does if command doesn't work properly?

I wrote this shell code, but it doesn't get the good output. Even though the $csoport gets the "...: No such user" output, id doesn't echoes the following line I wrote there. Thanks for yout help

 read felhasznalo
 while [ "$felhasznalo" != "exit" ]
 do
    csoport=`groups $felhasznalo`
    echo "$csoport"

    if [[ "$csoport" == *": No such user"* ]] ; then
            echo -n "Nincs ilyen felhasznalo a rendszerben"

    else
            echo "$csoport"
    fi
    echo -n "Felhasznalo: "
    read felhasznalo
 done

Aucun commentaire:

Enregistrer un commentaire