Taking in a text file and analzying it
Hi. Would like to write a shell program using bash, to take a given text file and analyze it to produce the frequency of characters in the file... I also want to report frequency of 1-letter word, 2 letter words till 4 letter words.
I'm very new to linux, and this is my first program. Can anyone please help me with it? I would love to write out something here, so that someone may correct me. But i just have no idea how to start. Example of an output would be something like this... Character used number of occurrence a 2 b 4 ------------------------------------------ Length of words used no. of occurence 1 letter word 1 2 letter word 3 3 letter word 2 4 letter word 8 Many thanks. |
Quote:
These bash scripting guides should get you started. http://tldp.org/LDP/abs/html/ http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html |
A simple Google search will even get you the actual script you need. Have fun "googling"
:) Linux Archive |
i am able to come out with something after some research. However, i don't know how i could report the frequency of 1-letter word up till 4-letter word in the codes. Since i have put the Field separator as "".
Another problem i'm hitting is, the program also counts and out put the whitespace that it encounters. Is there a way to make the program ignore the whitespace, or at least not print it? here's an example of my output now. echo i am testing | bash words.sh Character used Number of Occurrence 2 <<<can i get rid of this? tell the program not to print the count for whitespace? a 1 e 1 g 1 i 2 m 1 n 1 s 1 t 2 Quote:
|
Quote:
|
you should do your homework!!
And take a closer look to $ man awk and $ man cut |
All times are GMT -5. The time now is 05:17 PM. |