eolas/Programming_Languages/Shell/Case_statements_in_Bash.md

36 lines
402 B
Markdown
Raw Normal View History

2023-02-21 07:34:13 +00:00
---
categories:
- Programming Languages
tags:
- shell
---
# Case statements in Bash
```bash
function convertCharToInt {
case $1 in
A | X )
echo 1
;;
B | Y )
echo 2
;;
C | Z )
echo 3
;;
*)
echo 0
;;
esac
}
```
Usage:
```bash
declare -i intValue = $(convertCharToInt B)
```