awk -F "|" '{
for(i=1;i<=NR;i++)
{
da=0.25*$2; hra=0.50*$2; gp=da+hra+$2;
printf "Name:%-10s Basic:%-6.2f HRA:%-6.2f DA:%6.2f GrossPay:%-6.2f\n",$1,$2,$2*.5,$2*.25,$2*1.75
}
}' dataBaseSalary
OUTPUT:-
#!/bin/bash
#root@slack-linunx:~/scripts#cat dataBaseSalary
#Jack|8000
#Steven|11000
#Nora|12000
#Pete|10000
#Alex|15000
#root@slack-linunx:~/scripts#./grossSalary.sh
#Name:Jack Basic:8000.00 HRA:4000.00 DA:2000.00 GrossPay:14000.00
#Name:Steven Basic:11000.00 HRA:5500.00 DA:2750.00 GrossPay:19250.00
#Name:Nora Basic:12000.00 HRA:6000.00 DA:3000.00 GrossPay:21000.00
#Name:Pete Basic:10000.00 HRA:5000.00 DA:2500.00 GrossPay:17500.00
#Name:Alex Basic:15000.00 HRA:7500.00 DA:3750.00 GrossPay:26250.00
#root@slack-linunx:~/scripts#
for(i=1;i<=NR;i++)
{
da=0.25*$2; hra=0.50*$2; gp=da+hra+$2;
printf "Name:%-10s Basic:%-6.2f HRA:%-6.2f DA:%6.2f GrossPay:%-6.2f\n",$1,$2,$2*.5,$2*.25,$2*1.75
}
}' dataBaseSalary
OUTPUT:-
#!/bin/bash
#root@slack-linunx:~/scripts#cat dataBaseSalary
#Jack|8000
#Steven|11000
#Nora|12000
#Pete|10000
#Alex|15000
#root@slack-linunx:~/scripts#./grossSalary.sh
#Name:Jack Basic:8000.00 HRA:4000.00 DA:2000.00 GrossPay:14000.00
#Name:Steven Basic:11000.00 HRA:5500.00 DA:2750.00 GrossPay:19250.00
#Name:Nora Basic:12000.00 HRA:6000.00 DA:3000.00 GrossPay:21000.00
#Name:Pete Basic:10000.00 HRA:5000.00 DA:2500.00 GrossPay:17500.00
#Name:Alex Basic:15000.00 HRA:7500.00 DA:3750.00 GrossPay:26250.00
#root@slack-linunx:~/scripts#
0 comments:
Post a Comment