Shell scripting basics

We all sometimes feel that there can be some machine which can do your work so that you can concentrate on more innovations. Shell scripting is one of the powerful techniques to automate your daily tasks.In Linux, bash scripting is one of the common shell which we can invoke from the command line.
We are going to see how to create,edit and execute a shell script in Linux.
We can use a vi editor to write a shell script.
In Linux terminal,give the following:
~]$ vi file_name
Every bash script starts with the line:
#!/bin/bash
where #! is called sharp + bang also called as shebang for invoking the bash executable from binary.
For example: I want to clean up the logfiles using a shell script for specific log directory for a every two days.I write a shell script like:
#!/bin/bash
find /path/to/files/ -type f -name '*.log' -mtime +2 -exec rm {} \;
—-> give ‘shift key’ + : + wq to exit the vi editor
Give permissions to the file to execute:
chmod -R 755 filename
To execute a shell script:
use “./ + filename”
example: If your file is present in current working directory you have to use “./”
./filename
if your file is present in some other directory ,then set the variable $PATH as :
export PATH=/path/to/executable file
eg:export PATH=/bin/sqlplus
To check the path of the executable file
echo $PATH
We will see more in further posts.Thank you!!!