Answer:
Script is given below
Explanation:
Below is the AWK code for the Report.I have used the sample data that your have shared in the question.
AWK code-
echo "Hello World!"
echo "2011 Jan X 29.44 17.33 43.21" > inputfile.txt
echo "2014 Jan Y 32.32 12.12 99.00 1.99 " >> inputfile.txt
echo "2012 Jan X 321.11 12.34 10.99" >> inputfile.txt
echo "2012 Feb Y 1.99 12.75" >> inputfile.txt
echo "2012 Feb X 32.99 65.78 98.76" >> inputfile.txt
echo "2014 Jan Y 12.99 17.44 21.34" >> inputfile.txt
echo "2012 Mar X 11.45" >> inputfile.txt
awk -F" " 'BEGIN{ X_sum=0;
print(" Sales Data for year 2014")
print("========================")
}
{ if($1=="2014")
{
print($2,":", $4+$5+$6+$7+$8+$9+$10+$11+$12+$13)
}
if($3=="X")
{
X_sum=X_sum+$4+$5+$6+$7+$8+$9+$10+$11+$12+$13
}
if($3=="Y")
{
Y_sum=Y_sum+$4+$5+$6+$7+$8+$9+$10+$11+$12+$13
}
if($3=="Z")
{
Z_sum=Z_sum+$4+$5+$6+$7+$8+$9+$10+$11+$12+$13
}
}
END { print(" ========================")
print("Station volume for 2014 is:")
print("X:" ,X_sum )
print("Y:" ,Y_sum )
print("Z:" ,Z_sum )
}
' < inputfile.txt