eolas/Programming_Languages/Shell/Control_flow.md

14 lines
460 B
Markdown
Raw Normal View History

2022-04-23 13:26:53 +01:00
---
2022-09-06 15:44:40 +01:00
categories:
- Programming Languages
2022-04-23 13:26:53 +01:00
tags:
- shell
---
## If statements
2022-09-06 15:44:40 +01:00
- Conditional blocks start with `if` and end with the inversion `fi` (this is a common syntactic pattern in bash)
- The conditional expression must be placed in square brackets with spaces either side. The spaces matter: if you omit them, the code will not run
- We designate the code to run when the conditional is met with `then`
- We can incorporate else if logic with `elif`