0% found this document useful (0 votes)
11 views14 pages

Introduction to Shell Programming

A shell script is a program for Unix/Linux that performs operations like file manipulation and program execution. The shell serves as an interface to the Unix system, interpreting commands entered by the user through a command prompt. There are various types of shells, including Bourne and C shells, each with its own commands and functions, and scripts can include user input and comments.

Uploaded by

Nobery Enkurey
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views14 pages

Introduction to Shell Programming

A shell script is a program for Unix/Linux that performs operations like file manipulation and program execution. The shell serves as an interface to the Unix system, interpreting commands entered by the user through a command prompt. There are various types of shells, including Bourne and C shells, each with its own commands and functions, and scripts can include user input and comments.

Uploaded by

Nobery Enkurey
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Shell Programming

Shell Script
 A shell script is a computer program
designed to be run by the Unix/Linux.
 A shell is a command-line interpreter and

typical operations performed by shell scripts


include file manipulation, program
execution, and printing text.
What is Shell
 A Shell provides you with an interface to
the Unix system. It gathers input from you
and executes programs based on that input.
When a program finishes executing, it
displays that program's output.
 Shell is an environment in which we can run

our commands, programs, and shell scripts.


There are different flavors of a shell, just as
there are different flavors of operating
systems. Each flavor of shell has its own set
of recognized commands and functions.
Shell Prompt

 The prompt, $, which is called


the command prompt, is issued by the
shell. While the prompt is displayed, you
can type a command.
 Shell reads your input after you

press Enter. It determines the command


you want executed by looking at the first
word of your input. A word is an unbroken
set of characters. Spaces and tabs separate
words.
Shell Types

In Unix, there are two major types of shells −

 Bourne shell − If you are using a Bourne-type shell,


the $ character is the default prompt.
 C shell − If you are using a C-type shell, the % character is the
default prompt.

The Bourne Shell has the following subcategories −


 Bourne shell (sh)

 Korn shell (ksh)

 Bourne Again shell (bash)

 POSIX shell (sh)

The different C-type shells follow −


 C shell (csh)

 TENEX/TOPS C shell (tcs


Shell Script Examples

 echo "Hello world“


Shell Script Arguments
 echo "My first name is $1"
 echo "My surname is $2"
 echo "Total number of arguments is $#"
Use of comment:

 ‘#’ symbol is used to add single line


comment in bash script. Create a new file
named ‘comment_example.sh’ and add
the following script with single line
comment.

 # Add two numeric value


((sum=25+35))

#Print the result


echo $sum
Get User Input:

Get User Input:


 ‘read’ command is used to take input from

user in bash. Create a file named ‘user


[Link]’ and add the following script for
taking input from the user. Here one string
value will be taken from the user and
display the value by combining other string
value.
 echo "Enter Your Name"

read name
echo "Welcome $name to Tusar"
THANK YOU

You might also like