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
-
UpdatedOct 23, 2014
-
Views30,959
You May Like
Write a Shell script to find factorial of a given integer.
Write in C the following Unix commands using system calls A). cat B). ls C). mv
Write a Shell script that displays list of all the files in the current directory to which the user has read, Write and execute permissions.
Write a Shell script that accepts a filename, starting and ending line numbers as arguments and displays all the lines between the given line numbers.
Write a C program to emulate the Unix ls-l command.
Write a Shell script to list all of the directory files in a directory.