case (Unix)
A case a Unix shell beépített utasítása többirányú elágazás programozására. Alakja:
case szó in minta1|minta2...) utasítás1... ;; minta3|minta4...) utasítás2... ;; ... esac
Az utasítás egymás után megpróbálja szó-t illeszteni a megadott mintákra. Ha valamelyik minta egyezik, annak utasításai hajtódnak végre ;;
-ig. A mintaillesztés a fájlok wildcard-jával azonos módon történik.
Külön default ág nincs, de a *
minden szóra illeszkedik.
Példa:
read -p "Irj be egy sort! " SOR
echo A beirt sor: "$SOR"
case "$SOR" in
.*) echo Ponttal kezdodo sor
;;
?) echo Egy betubol allo szo
;;
*\ *) echo Helykoz van benne
;;
*[0-9]*) echo Szamjegy van benne
;;
*[A-Za-z]*) echo Betu van benne
;;
"") echo Nem is irtal be semmit!
;;
*) echo Fogalmam sincs, mi ez
;;
esac
Források
[szerkesztés]- Bash Reference Manual (gnu.org)
Unix parancssoros programok és utasítások | |
---|---|
Fájlrendszer | |
Processzek | |
Felhasználói környezet | |
Szövegkezelés | |
Shell programozás | |
Hálózat | |
Keresés | |
Dokumentáció | |
Egyéb |
Text is available under the CC BY-SA 4.0 license; additional terms may apply.
Images, videos and audio are available under their respective licenses.