Ethical Hacking Journal Part 6: Shell Scripting Basics

DISCLAIMER: The content of this post/blog is based on opinion on what I have learned and for educational purposes, therefore if there are any mistakes or recommendation for improvement leave a comment 🙂



In this post I will talk about Shell Scripting, so Shell Scripting is like programming. So people will find common phrases or syntax using this tool.

You start by changing your directory to an empty folder, in this case I used the Document directory.

Make a new script file with the command below:


touch script.sh


The command above will create a file called script.sh, this file will be used to run the shell scripting language.

Then in order to run the file later, enter the following command.


chmod a+rx script.sh


Then in order to run the script you can enter the command:


./script.sh


But of course nothing will happen because the file is empty, so let us type some code in the file.

To print a string, you can use the function echo to print.

To make a variable, the method is the same like python.

To read input, you can use the function read.

And as you can see, when I run the script,  the program asks me for an input and after my input, it is immediately outputted.

The syntax {1..5}: specifies that the for loop should loop the number from 1 to 5.

Output:

Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *