AWK count letters words


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting AWK count letters words
# 1  
Old 07-20-2012
AWK count letters words

Hi All!

can anyone help me with this code?
I want to count words or letters in every line with
Code:
if(count>20){else echo $myline}

Code:
awk  '/<script /{p=1} /<\/script>/{p=0; next}!p' index.html |  while read myline; do
[count here if,else]
    echo $myline
done

Thank you !!!
# 2  
Old 07-20-2012
perl

Hi,

Try this one,
Code:
echo ${myline} | perl -ne '$t=$_;$c=$t=~s/[^ ]\s+[^ ]//g;print "Words:$c\nLetters:",length($_),"\n";'

Cheers,
Ranga:-)
This User Gave Thanks to rangarasan For This Post:
# 3  
Old 07-20-2012
${#myline} will give you the length of myline.

wc can count letters, words, and lines.

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 4  
Old 07-20-2012
Quote:
Originally Posted by alister
${#myline} will give you the length of myline.
Thank you
You're great!!!

I have one last question for the "if"
can you tell me where is the problem here?

Code:
awk  '/<script /{p=1} /<\/script>/{p=0; next}!p' index.html |  while read myline; do
counts=${#myline}
if ($counts>20) {  echo $myline }
else{}
done

Thank you guys!

Last edited by sanantonio7777; 07-20-2012 at 07:47 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find words containing small letters

Hello, I have a file containing different words. How can i print the words which contain at least one small letter, for example if i have: today TOMORROw 12345 123a next preViou5 no it should print the following: today TOMORROw 123a next preViou5 no Please use code tags as required... (5 Replies)
Discussion started by: JhonTheNewbie
5 Replies

2. Shell Programming and Scripting

Count words/lines between two tags using awk

Is there an efficient awk that can count the number of lines that occur in between two tags. For instance, consider the following text: <s> Hi PP - my VBD - name DT - is NN - . SENT . </s> <s> Her PP - name VBD - is DT - the NN - same WRT - . SENT - </s> I am interested to know... (4 Replies)
Discussion started by: owwow14
4 Replies

3. Shell Programming and Scripting

How count the number of two words associated with the two words occurring in the file?

Hi , I need to count the number of errors associated with the two words occurring in the file. It's about counting the occurrences of the word "error" for where is the word "index.js". As such the command should look like. Please kindly help. I was trying: grep "error" log.txt | wc -l (1 Reply)
Discussion started by: jmarx
1 Replies

4. UNIX for Dummies Questions & Answers

Grep search for count of letters beginning with a certain letter

Say I have a text file (allWords.txt), that contains all the words in the dictionary, line by line, that I would like to search through. Here is a snippet of what it might looks like... Code: a aah aahed aahing aahs aardvark aardvarks aardwolf ab abaci aback abacus abacuses abaft ...... I... (1 Reply)
Discussion started by: blackvelvet
1 Replies

5. Shell Programming and Scripting

Find and arrange words with same letters from list

I am making a word game and I am wondering how to find and arrange words in a list that have the same letters. In my game, you are presented with 5 letters, and you then have to rearrange the letters tp make a word. So the word could be "acorn", but those 5 letters could also make up "narco" or... (2 Replies)
Discussion started by: hellobard
2 Replies

6. UNIX for Dummies Questions & Answers

Grep.Need help with finding the words which start at [A-K] letters in thesecond column of the table

Hi buddies ! I need some help with one grep command :) I have this table: 1 Petras Pavardenis 1980 5 08 Linas Bajoriunas 1970 10 3 Saulius Matikaitis 1982 2 5 Mindaugas Stulgis 1990... (1 Reply)
Discussion started by: vaidastf
1 Replies

7. Shell Programming and Scripting

ENQUIRY WHETHER SCRIPT FOR DETECTING WORDS FROM A SET OF LETTERS EXISTS

Hello, I am interested in finding out whether someone has a perl or awk script which takes a set of letters such as wak and referring to a dictionary spews out all possible forms such as awk, kaw etc. If someone has such a script, could it be put up please. The script should handle Unicode. Many... (0 Replies)
Discussion started by: gimley
0 Replies

8. Shell Programming and Scripting

Shell script to find out words, replace them and count words

hello, i 'd like your help about a bash script which: 1. finds inside the html file (it is attached with my post) the code number of the Latest Stable Kernel, 2.finds the link which leads to the download location of the Latest Stable Kernel version, (the right link should lead to the file... (3 Replies)
Discussion started by: alex83
3 Replies

9. Shell Programming and Scripting

awk help needed in trying to count lines,words and characters

Hello, i am trying to write a script file in awk which yields me the number of lines,characters and words, i checked it many many times but i am not able to find any mistake in it. Please tell me where i went wrong. BEGIN{ print "Filename Lines Words Chars\n" } { filename=filename + 1... (2 Replies)
Discussion started by: salman4u
2 Replies

10. Shell Programming and Scripting

extract words with even numbr of letters

Hello All I need to extract words which are of even number of letters and not greater than 10. Any help?? Thanks, Manish (3 Replies)
Discussion started by: manish205
3 Replies
Login or Register to Ask a Question