Results 1 to 6 of 6
Hi, I want to write some code to search for a specific string in a text file, but without using grep command.
Thanks....
- 10-27-2010 #1Just Joined!
- Join Date
- Oct 2010
- Posts
- 3
find a string in a file without using grep
Hi, I want to write some code to search for a specific string in a text file, but without using grep command.
Thanks.
- 10-27-2010 #2
- 10-27-2010 #3Just Joined!
- Join Date
- Oct 2010
- Posts
- 3
well, thank you very much, but I want to write C code to do the job...
How can I write the code to search for e.g. the word "test" in the file "myfile.txt" without using grep command...
- 10-27-2010 #4
This sounds like a homework question. Think it through. Run through the searching process manually on paper. Essentially you want to do just what a human would do, look for the pattern starting with the first character, then look at each subsequent character. If you get a mismatch, then start the pattern again.
- 10-27-2010 #5Just Joined!
- Join Date
- Oct 2010
- Posts
- 3
well yes it is a homework...You mean that there is not something special in linux to search a string in a file, like for example "sort " command.
So I have to hardcode it...?
- 10-27-2010 #6
Well even if there is it is against the forum rules to ask homework questions


