Go Back   PCMech Forums > Linux Support > Linux OS and Software Assistance

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 03-29-2002, 02:39 PM   #1
Member (8 bit)
 
Join Date: May 2000
Posts: 219
Smile Linux Shell for a simple program :)

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
copyright_1978 is offline   Reply With Quote
Old 03-30-2002, 03:58 AM   #2
Member (8 bit)
 
Join Date: May 2000
Posts: 219
Anyone?
copyright_1978 is offline   Reply With Quote
Old 03-30-2002, 05:19 PM   #3
Member (9 bit)
 
Join Date: Jan 2000
Location: Atwater Mn. USA
Posts: 429
Honestly I don't have an answer myself. But I know that somebody over at linuxjunior.org will.

OOPS!
__________________
If you think you understand what's going on. Then you haven't been paying attention.
OOPS! is offline   Reply With Quote
Old 03-31-2002, 12:20 AM   #4
Member (4 bit)
 
Join Date: Mar 2002
Location: Denver
Posts: 14
Lightbulb I'm working on this

Hi, I saw your message and I'm working on this. Instead of saying
"Use grep then add some more commands using awk, and sed....bla, bla..." I'm working on a script based on your questions so that I can give you some ideas for your project. Hope to have an answer soon.
abrakadabra is offline   Reply With Quote
Old 03-31-2002, 04:36 AM   #5
Member (8 bit)
 
Join Date: May 2000
Posts: 219
Thanks alot you guys. Abrakadabra thanks for your help, I just need some simple grep or sed or wc commands to help me work this out, if you know any other way please let me know. I appreciate this very much.
copyright_1978 is offline   Reply With Quote
Old 04-01-2002, 11:35 AM   #6
Member (4 bit)
 
Join Date: Mar 2002
Location: Denver
Posts: 14
Post

Hey, here is some info I found for you. Since I'm not sure exactly how you want your scrip to look like, I was searching some of my favorites for tips on what you want and found this link. Although is for bash scripting you can make the necessary changes if you are using a different shell. http://linuxdoc.org/LDP/abs/html/
Hope this helps. Let me know.
abrakadabra is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 06:01 PM.
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.0