Subscribe:

Pages

Text

Recent Articles

Nike Sports

Ads 468x60px

Recent Posts

Google Plus

Download

Featured Posts

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