1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-03-28 21:16:20 +01:00
tldr/pages.it/common/case.md
2021-04-18 15:33:27 +01:00

12 lines
500 B
Markdown

# case
> Esegui branch diversi in base al valore di un'espressione.
> Maggiori informazioni: <https://manned.org/case>.
- Esegui il match di una variabile su diverse stringhe per decidere che comando eseguire:
`case {{$metrica}} in {{parole}}) {{wc -w README}}; ;; {{linee}}) {{wc -l README}}; ;; esac`
- Combina pattern con |, utilizzando * come pattern di fallback:
`case {{$metrica}} in {{[pP]|parole}}) {{wc -w README}}; ;; {{[lL]|linee}}) {{wc -l README}}; ;; *) {{echo "cosa?"}}; ;; esac`