Pages

Text

Recent Articles

Nike Sports

Ads 468x60px

Recent Posts

Google Plus

Download

Thursday, 12 April 2012

Write a shell script to read a basic salary of an employee, if basic salary is less than or equal to 5000 then DA will according to 50% of the basic salary and gross salary will be computed as DA + basic salary. If basic salary greater than 5000 then DA according to 25% of basic salary and gross will be DA + basic.

#! /bin/sh
# Write a shell script to read a basic salary of an employee, if basic salary is less than or equal to 5000 then DA will according to 50% of the basic salary and gross salary will be computed as DA + basic salary. If basic salary greater than 5000 then DA according to 25% of basic salary and gross will be DA + basic.
echo "Enter the basic salary of an employee "
read basic
if test $basic -le 5000
then
DA=0.5*$basic
gross=$DA +$basic
echo "The gross salary of an employee is "
echo $gross
else

DA=0.25*$basic
gross=$DA +$basic
echo "The gross salary of an employee is "
echo $gross
fi

Write a shell script to read a basic salary of an employee, if the basic salary is less than or equal to 1500 then display the message as the employee type is class-3 otherwise display the message is employee class-2

#! /bin/sh
# Write a shell script to read a basic salary of an employee, if the basic salary is less than or equal to 1500 then display the message as the employee type is class-3 otherwise display the message is employee class-2.
echo " Enter the employee basic salary "
read basic
if test $basic -le 1500
then
echo "The employee type is class-3 "
else
echo "The employee type is class-2 "
fi

Write a shell script to read a number from user and check whetherhe message numm the number is less than or equal to 99, if it is less than 99 then display the message number is less than 99 otherwise number is greater.

#! /bin/sh
# Write a shell script to read a number from user and check whetherhe message numm the number is less than or equal to 99, if it is less than 99 then display the message number is less than 99 otherwise number is greater.
echo "Enter the number "
read number
if test $number -le 99
then
echo "The entered number is less than or equal to 99 "
else
echo "The number is greater than 99 "
fi

Write a shell script that reads a pattern and a file name from the keyboard, if the file exist then pattern should be search on the file and display accordingly where the pattern is matched otherwise display file not found.

#! /bin/sh
# Write a shell script that reads a pattern and a file name from the keyboard, if the file exist then pattern should be search on the file and display accordingly where the pattern is matched otherwise display file not found.
echo " Enter the file name "
read filename
if ls $filename
then
echo "enter the pattern "
read pattern
grep $pattern $filename
else
echo " File doesn't exist "
fi

Write a shell script to check wether the file exist in the current directory, if the file exist then display the contents of the file else display the file not found in the current directory.

#! /bin/sh
# Write a shell script to check wether the file exist in the current directory, if  the file exist then display the contents of the file else display the file not found in the current directory.
echo "Enter the file name "
read file
if ls $file
then
cat $file
else
echo "The given file is not found in current directory "
fi

Write a shell program to copy, read two files name the keyboard and copied the contents of source file into the destination file. (f1 to f2).

#! /bin/sh
# Write a shell program to copy, read two files name the keyboard and copied the contents of source file into the destination file. (f1 to f2).
echo " Enter the two files (source file and destination file)"
read sfile dfile
if cp $sfile $dfile
then
echo "copied the contents of source file to destination file successfully "
else
echo "Doesn't copied successfully "
fi

Program to print the name of the shell script sunning

# /bin/sh
# Program to print the name of the shell script running.
echo " The number of inputs entered "
echo $#
echo "Name of the shell script running "
echo $0
echo "First argument line in the command line is "
echo $1 

A Shell script takes the input from the command line and prints the number of commands line arguments entered.

#! /bin/sh
# A Shell script takes the input from the command line and prints the number of commands line arguments entered.
echo "The number of inputs entered is "
echo $#

A script reads a pattern name & file name from a user & displays the pattern that is matched into a file onto a screen.Post title


#! /bin/sh
# A script reads a pattern name & file name from a user & displays the pattern that is matched into a file onto a screen.
echo ”Enter the pattern name to be searched”
read pattern
printf ”The entered pattern name is %s /n ” $pattern
echo "Entered file name "
read file
printf "The entered name of the file is %s /n " $file
grep $pattern $file

A script reads a input from keyboard and print the input on the screen.


#! /bin/sh
# A script reads a input from keyboard and print the input on the screen.
echo “Enter the input please”
read input
echo “The entered input is /n”
printf $input

Program to display a simple message from a shell script.


#!/bin/sh
# Program to display a simple message from a shell script.
echo “first line in the script “
echo “Today date is 10 April “