Hi, I'm fairly new at shell scripting and I'm trying to create a small menu system for someone. It's a small script that is designed to analyse a file containing some text. (using Linux, Mandrake 7.2 to be precise).
I'm currently stuck on the following items:
1) I'm trying to get a specific letter count. For example, if someone wanted to count the number of 'f' in a text file, how would I do that.
2) How do I do aword count that can be specified, for example 'milk' in a text file.
3) A sentence count.
4) Add an extra line to the text
5) Replace a word in a text
I know it has something to do with grep, sed and wc, but I can't get around to piping them correctly.
Just one other thing, How do I get a menu system to work? I currently have a menu system that you can chose options such as:
[1] Open file
[2] List File
[3] Word count
I did this using functions but after the menu function has been executed once, then I call it from another function it doesn't seem to work, this is how my structure is:
function menu
{
menu code
option1 #this line calls the function option
}
menu #this line calls the function menu above
function option1
{
Option code
menu # this line is the problem, it calls the function, but the menu function doesn't work properly
}
Thank you for any help


Reply With Quote
Bookmarks