Write a awk script to find the number of characters, words and lines in a file.

AIM:

Write a awk script to find the number of characters, words and lines in a file.

Program:

BEGIN{print "record.\t characters \t words"}
#BODY section
{
len=length($0)
total_len =len
print(NR,":\t",len,":\t",NF,$0)
words =NF
}
END{
print("\n total")
print("characters :\t" total len)
print("lines :\t" NR)
}

Output:

Student@ubuntu:~$ awk –f cnt.awk ff1
Record  words
1:           5:            1hello
Total
Characters:5
Lines:1