Starting With Shell Script

What is a shell script?

A shell script is a command which would have been directly typed into a shell.

It can be a sequence of commands that you type regularly.By putting them into

a script we can reduce them to a single command.Also there is no difference in

syntax between interactive command line use and placing the commands in a

file.But there are some commands line history which we can only type in

interactive command line.

Why use shell scripts?

Shell scripts are used to combine lengthy and repetitive sequence of commands

into a single and simple command.We can create new commands using combinations

of utilities.It can also be used to generalize operations on a single set of data, into a

procedure that can be applied to any similar set of data.

Writing the script

First use one of the text editors like vi and write this inside it:

#!/bin/sh

clear

echo “Hello world”

and save the file using .sh extension,say hello.sh.

Making it executable

To do execute,tell linux that this is an executable file.

chmod +x hello.sh

Running the script

To run the script just go to the directory where the file is saved and type the following

command:

./hello.sh

The output will be:

 

 

Advertisements

About ramyabkrishna

I am Ramya B Krishna doing MCA at GEC Thrissur. I am now in the process of taking a Leap into the world of Linux and hoping to do a few projects as well.

Posted on August 6, 2011, in Uncategorized. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: