First of all apology for i had not wrote dairy yesterday. What should i do BSNL like to play hide and seek. I was working on my script. Finally i created a shell script for my project. Felling good, because the day when my “GURU” gave me that task everything bounced to my head. “GURU” said make script so that with single command your program installed there will be no manual work but i am confusing how to do that and what script he was asking me to do. When i came back to home i posted a mail in group to learn what kind of script he was talking. Many of my fellow and my “GURU” replied on that mail. Learning from their replies i came to know what actually script is. I immediately start searching about shell script as i choose this to write my script. So question arises what is shell script ?
SHELL SCRIPT :-
A shell script is a script written for the shell, or command line interpreter , of an os. The shell is often considered a simple domain-specific programming language.Typical operations performed by shell scripts include file manipulation, program execution, and printing text.
I learn shell from sites named:-
Writing script is so easy task you just have to type whatever commands you give in terminal. If u want to search what commands you type. Type command “history” it will show your past commands you used in terminal. We use echo command to write any comment. -i is known as “in place”. I used this with sed command sed command is used to replace any content with other content eg: if i want to change username with present working directory i.e pwd use following steps:
- echo ” “
- sed -i “s#/home/username#”$path”#g” ~/abc
#!bin/bash :- The # is just for commenting. When you add the ! you have a shebang line
which generally means, that if the file is made into an executable, that line
will be executed first. So if you dont have the !, what happens? Nothing, it’s
just a comment.
path=$PWD :- Here i define variable that points to pwd i.e present working directory. If you
run that command in terminal it will show your direct name which is presently
echo ” ” :- Echo i used to give comments
Sed :- Sed is a stream editor. A stream editor is used to perform basic text
transformations on an input stream (a file or input from a pipeline).
-i :- in-place. Edit files in place (makes backup if extension supplied)
~/abc :- ~/ this will take you to your home directory and abc is name of file
at where you want to change username.
I learned a lot. Discover many things. Thanks to “GURU” who gave me that task due to him i am able to learn something new. THANKS