Bash Scripting 101

What This Bash Script Does:
This is a short Bash script that counts from 1 to 5 and prints each number to the terminal. It's great for beginners who want to understand how loops work in Bash.
The Full Script: count.sh
#!/bin/bash
# A simple loop that counts from 1 to 5
for i in {1..5}
do
echo "Counting: $i"
done
How To Run It on Kali Linux
Step 1: Open your terminal
Step 2: Create the script file
nano count.sh
Paste the script into the file.
Step 3: Save and exit Press CTRL + X
Then press Y and hit Enter
Step 4: Make it executable
chmod +x count.sh
Step 5: Run the script
./count.sh
Output You Should See:
If you followed the steps correctly you should get the same result as the one below
Why this script is useful
It teaches you how loops work in Bash.
It’s a good template for any task that repeats — like file processing or automation.
It’s simple enough to practice scripting on Kali Linux.
what each code means;
code | Explanation |
#!/bin/bash | Tells the system to use bash to run the script |
for i in {1..5} | starts a loop from 1-5 |
do ... done | defines what to do in each loop step |
echo "Counting: $i" | prints the current number to the terminal |
Subscribe to my newsletter
Read articles from Kamal Deen directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
