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

COMMANDS:

AWK: The awk is similar to sed it can be used for to edit the file.

NF: The NF can be used to count the number of fields on a records.

NR: The NR can be used to count the number of records on a file.

Mv:The mv command is used to move the data from one file to another file.

Syntax: mv file1 file2

				
					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)

 }
				
			

Leave a Reply