Skip to main content

Bash Scripting

Bash is a powerful Linux terminal application and bash scripting can be used to automate repetitive tasks easily. In this post, we will look at some basic bash scripting.

Bash scripting
[pre class="brush:bash"]

echo “Hello world…”
Sleep 1
echo “How are you?”
read ans
echo “you typed $ans”

chmod +x


How to run a bash script from anywhere
[pre class="brush:bash"]
# create a directory say "bin" under your home directory.
# update your path variable to include this bin directory.
#Put this in .profile or .bash_profle file to make it permanent.
export PATH=$PATH":$HOME/bin"
#or use the following if you want the directory to precedent system directories
# create a script say, "hello" and keep it in your bin directory.
#Give execute permission to the hello script.

echo My first program

# from any directory, you simply type:
$ hello
My first program[/pre]

You may also interested in reading: