Thursday 21 May 2015

Write an awk script to find out total number of books sold in each discipline as well as total book.VTU MCA UNIX LAB11A

BEGIN{
    printf("\n..........................................")
    printf("\nBranch \t NO of BOOks")
    printf("\n..........................................")
}
{
    books[$1]=books[$1]+$2
    total=total+$2
}
END{
    for(x in books)
    {
    printf("\n %-20s \t %d",x,books[x])
   
   
    }
    printf("\n.........................................")
    printf("\ntotal no of books sold: %d",total)
}

No comments:

Post a Comment