Bash by example - Introduction
Is this the first time you learn about bash? In this post, I will teach you how to write your first bash script using a simple example.
Let start with what is bash?
Bash (Bourne shell) is the shell, or command language interpreter, that will appear in most the *nix system. It offers functional improvements over sh (shell) for both programming and interactive use. In addition, most sh scripts can be run by bash without modification.
So why do you need to learn bash?
The answer is simple, by learning how to program in bash scripting, your daily interaction with *nix system is more fun as well as productive. A working knowledge of bash shell scripting is essential to anyone wishing to become reasonably proficient at *nix system administration.
Now using your favorite editor, let start create a script called helloworld.sh. By convention, bash shell script have name ending with .sh, but it is not requisite. Below shows a very short script that writes a message on the screen.
#!bin/bash # # This is my first bash shell script # Kelvin printf "Hello bash world! Bash is wonderfull." exit 0
Save the file, and then run the./helloworld.sh from the command line.
You will see Hello bash world! Bash is wonderfull. printed out on the screen.
Congratulation, and welcome to the world of bash.












Post a Comment