Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
counting occurences of a keyword
Name: Infinite Recursion Date: March 5, 2004 at 06:19:57 Pacific OS: na CPU/Ram: na
Comment:
does anyone know of a function that will allow me to count the occurences of a keyword in a text file? im trying to count the number of calls to strlcpy that i am making in my c code.
Name: Don Arnett Date: March 5, 2004 at 09:53:14 Pacific
Reply:
You don't mention your OS.
In UNIX/Linux, you can use grep and wc to count occurrences
cat myprog.c | grep strlcpy | wc -l
The above command will tell you how many lines in myprog.c contain the string 'strlcpy'. Note, that isn't necessarily the same thing as the number of occurrences of 'strlcpy' (more than one occurrence on a line?)
0
Response Number 2
Name: wizard-fred Date: March 5, 2004 at 17:06:12 Pacific
Reply:
Some word processors and text editors have a count function. Some might be part of the search/replace function.
Summary: Sounds like a classic case of a user with very restrictive rights. ===================================== If at first you don't succeed, you're about average. M2...
Summary: Alright, taking a file called test.txt and reading it in to count the words and spit back out into a differt txt file called counts that gives the single words used and how many times they are used ea...
Summary: I need to count no. of commas in each line of a csv file which contains text with spaces: e.g. below text in a file [mig@cpeuidb bin]$ cat cmt.txt_bkp this, is a ,comma ,count test1 this, is a ,comma...