Skip to content

KALI – How to write the BOOM Script – For Loops – The Visual Guide

27/07/2014

Bash Scripting allows the creation of “for loops”.  Here we make the boom script using bash scripting in nano.

Step 1 – Open Nano

nano boom.sh

{This creates a file called boom.sh}

Step 2 – Enter this code

 #!/bin/bash

for i in `seq 10 -1 1`

do

echo -en “${1} …”

done ; echo “BOOM”

boom script

Step 3 – Save the Script

Ctrl+O = save the script

It should automatically name itself boom.sh

Ctrl+X = exit nano

****

Step 4 = Make the script executable

chmod +x boom.sh

Step 5 – Run the boom script

./boom.sh

boom outputFor loops work on FIXED lists of items

Here it counts down from 10 to 1, minus 1 at each loop.

It display the variable each time

At the end of the program, after the for loop has completed it prints out “BOOM”.

boom output 2

 

References

University of South Wales Reading list

PARKER, S.  2011.  Shell Scripting – Expert recipes for Linux, Bash, and More.  Indianapolis: John Wiley & Sons.

 

KALI – First things to do after installing Kali Debian Linux – The Visual Guide

https://uwnthesis.wordpress.com/2014/07/20/kali-first-things-to-do-after-installing-kali-debian-linux-the-visual-guide/

Advertisements
One Comment
  1. socket2012 permalink

    You can put this code line instead of loop for to reach the same goal:
    for i in {10..1}

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: