Today I have tired with shell script which are meaningful and it is something I will remember as well. Lets first discuss about writing sample shell script!
1. Decide about a place to place your shell scripts. Usually it can be /home/yourUserDir/bin (/home/satya/bin)
So, create a directory if it does not exist.
Go to your home (~) dir and run
2. create a file using a text editor. I used vi to create a shell script. First cd into bin/ directory.
3. Write any command you run on shell prompt.
4. Close the file and give it a executable permission.
$chmod 755 testsh
$chmod ugo+x testsh
5. Use the script you just created.
It should output your path info.
6. Now, it may be running as you are inside bin/ directory.
You can include the bin/ folder in the PATH of executable. Open your .bashrc (dot bashrc) file and append your path (/home/yourUserId/bin) to the path.
Usually in this format:
Run it on your command line to activate new changes you made:
7. Check your path ($PATH) is updated or not!
If you see your newly added path along with old path then it is all correct.
Try running your script from anywhere. It will execute and give you output.
This was all you need to write shell script in Linux.
How to provide --help functionality to your shell script? Follow the post mentioned at the bottom, to know it.
Another post on shell scripting - Printing Full Path with Filename in Linux