![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| RegExp: From first occurrance to last (at line start) | jjinno | Shell Programming and Scripting | 6 | 01-08-2008 04:04 PM |
| finding duplicate files by size and finding pattern matching and its count | jerome Sukumar | Shell Programming and Scripting | 2 | 12-01-2006 04:20 AM |
| Finding Occurence of comma in a Variable ( KORN Shell) | DeepakXavier | Shell Programming and Scripting | 2 | 11-14-2005 04:44 AM |
| ksh: A part of variable A's name is inside of variable B, how to update A? | pa3be | Shell Programming and Scripting | 4 | 03-30-2005 12:29 PM |
| Finding out the length of a string held within a variable | dbrundrett | Shell Programming and Scripting | 5 | 02-19-2002 08:02 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Finding occurrance of a value in a variable
Hi,
I was given a question like this: Write a program which reads a set of arguments from the standard input. Note that there is no limit for the number of arguments. The first argument is the file name and the other arguments are searched in the given file. For each argument, it displays the lines of the file which include the argument and it displays the number of times the argument exists in the file. This process is repated for the other arguments. You need to consider error messages for the case of non-existing file, non-existing argument(s) and missing argument. I store the parameters in an array and decided the process the file line by line. Using head and tail, I get each line, but I can't come to a conclusion that if the word has an occurrance in that line. For example, our file is: Yesterday I played basketball. I love basketball. Basketball is good. And we take the first line "Yesterday I played basketball." Assuming that we are looking for word "basketball", how can I state that "basketball" exists in that line? (and how many times) Regards, ambitious Last edited by ambitious; 11-12-2005 at 06:39 AM.. |
|
|||||
|
You might want to review the rules of these forums, and in particular
(6) Do not post classroom or homework problems. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|