Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 285 Bytes

File metadata and controls

29 lines (20 loc) · 285 Bytes

Conditional Statements

Conditions allow scripts to make decisions.

If statement

Example:

#!/bin/bash

age=20

if [ $age -ge 18 ] then echo "Adult" fi

Output:

Adult If-Else statement #!/bin/bash

if [ -f file.txt ] then echo "File exists" else echo "File not found" fi