latest pushes
This commit is contained in:
31
bellos_scripts/control_structures.bellos
Normal file
31
bellos_scripts/control_structures.bellos
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bellos
|
||||
# File: control_structures.bellos
|
||||
|
||||
# Demonstrating if statements and loops
|
||||
|
||||
# If statement
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
echo "No arguments provided"
|
||||
elif [ $# -eq 1 ]
|
||||
then
|
||||
echo "One argument provided: $1"
|
||||
else
|
||||
echo "Multiple arguments provided"
|
||||
fi
|
||||
|
||||
# For loop
|
||||
echo "Counting from 1 to 5:"
|
||||
for i in 1 2 3 4 5
|
||||
do
|
||||
echo $i
|
||||
done
|
||||
|
||||
# While loop
|
||||
echo "Countdown:"
|
||||
count=5
|
||||
while [ $count -gt 0 ]
|
||||
do
|
||||
echo $count
|
||||
count=$((count - 1))
|
||||
done
|
Reference in New Issue
Block a user