Learning Bash Scripting

I thought of learning bash scripting. I do not know how tough is it gonna be. I have not looked at the whole complicated script at all.
I am gonna begin with a simple bash script.

First I need to locate where my bash interpreter is located.
In my case its located in /usr/local/bin/bash

(~) - which bash
Now I am making a simple bash script that would echo(print a string on my scren)
(manoj@linuxweblog.com)touch first_bash.sh
(manoj@linuxweblog.com)vi first_bash.sh

Every bash script begins with a #! ( Sha bang ) followed by the location of the bash interpreter. **#! does not determine/mean a comment**

a simple script.

#Declaration of the location of bash interpreter
#Declaration of a String Variable
STRING="My first Batch Script"
#Printing the string variable on the screen
echo $STRING

Running the bash script.
Before running bash script we need to make sure its file permissions are ok and they are executable.
(manoj@linuxweblog.com)chmod +x first_bash.sh
~My first Batch Script

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Variables on Bash Scripting

Global and Local Variables

#Declare global varibale *can be used anywhere in the script*
VAR="This is global variable"
function bash {
#Declare local variable which is local to function bash only
local VAR="This is local variable"
#This will still print Global variable
echo $VAR
#Using function bash ,we can print local variable
echo $VAR

#Print A global Variable Again
Echo $VAR