Write a script to calculate gross salary for any number of employees.

Gross Salary =Basic + HRA + DA.

HRA=10% and DA= 15%.

len=cat Emp.txt | wc -l

while [ $len -gt 1 ]

do

line=cat Emp.txt| head -$len | tail -1

Name=echo $line |cut -f 2 -d ":"

B_salary=echo $line |cut -f 7 -d ":"

HRA=echo $B_salary \* 0.10 |bc

DA=echo $B_salary \* 0.15 |bc

GROSS=echo $HRA + $DA + $B_salary |bc

echo -e “\n Employee Name:”$Name “\n———————————–\nBasic Salary  : ” $B_salary “\nHRA           : ” $HRA ”

nDA            : ” $DA “\nTotal Gross Salary: “$GROSS

len=expr $len - 1

done

 

OUTPUT::

 

Employee Name:DEVI

———————————–

Basic Salary  :  30000

HRA           :  3000.00

nDA            :  4500.00

Total Gross Salary: 37500.00

 

Employee Name:DEV

———————————–

Basic Salary  :  45000

HRA           :  4500.00

nDA            :  6750.00

Total Gross Salary: 56250.00

 

Employee Name:RICHA

———————————–

Basic Salary  :  25000

HRA           :  2500.00

nDA            :  3750.00

Total Gross Salary: 31250.00

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.