Linux Fundamentals - Part 7: Bash Scripting (If Statements)

Published: (February 3, 2026 at 07:20 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

If Statements

If statements execute code based on a condition. If the condition is true, the code block will run.

The condition is enclosed in square brackets [ ] and the statement ends with fi, which is if spelled backward, marking the end of the if block.

Example: Basic If Statement

num=15
if [ $num -gt 10 ]; then
   echo "Number is greater than 10"
fi

If…Else Statements

Back to Blog

Related posts

Read more »

Termux

Article URL: https://github.com/termux/termux-app Comments URL: https://news.ycombinator.com/item?id=46854642 Points: 4 Comments: 0...