how to count Character in file
Code:
#!/usr/bin/awk -f #Usage: count_word word=<word_to_count> input_file(s) #Assume word is delimited by non alphabetic characters NR==1 { re_word = "(^|[^[:alpha:]])" word "([^[:alpha:]]|$)" ;print re_word} { count += gsub(re_word,"_") } END { print count }
Code:
#!/usr/bin/awk -f #Usage: count_char char=<char_to_count> input_file(s) NR==1 { char =substr(char,1,1) } { count += gsub(char,"_") } END { print count }
Code:
#!/usr/bin/awk -f #Usage: count_sentances input_file(s) { count += gsub(/.([.!?:]+|$)/,"_") } END { print count }
No comments:
Post a Comment