searching for text in a fie
Posted: 26 Apr 2018, 17:36
Hi everybody,
I have stumbled upon an issue where i desperately need some help. I need to find whether a string (for example the string "belzebub") can be found in a fairly big (atm about 20Meg file abc.log) on my disk. I know that the text is, if it is, among the last f.ex. 1000 bytes. No other occurancies are relevant but the last occurance.
So somehing like this:
found := 0
open file C:\path\abc.log/ re-read file the file abc ; re-read the file because the text, if it exists has been added fairly recently by another program
read from the end of the file
read last 1000 bytes
search for the text ”belzebub” in the last bytes searching from the end
if the text is found
{
found_pos := position ; mark position where was found
found := 1 ; mark that text was found
return
}
return ; nothing was found, all is done
Could somebody point me in the right direction? Any help would be appreciated. Which commands are necessary when opening / re-reading the file, how to tell the program where it should be read, how to search for the text, all this in to say the least unclear to me.
Thank you.
--=kallera=--
I have stumbled upon an issue where i desperately need some help. I need to find whether a string (for example the string "belzebub") can be found in a fairly big (atm about 20Meg file abc.log) on my disk. I know that the text is, if it is, among the last f.ex. 1000 bytes. No other occurancies are relevant but the last occurance.
So somehing like this:
found := 0
open file C:\path\abc.log/ re-read file the file abc ; re-read the file because the text, if it exists has been added fairly recently by another program
read from the end of the file
read last 1000 bytes
search for the text ”belzebub” in the last bytes searching from the end
if the text is found
{
found_pos := position ; mark position where was found
found := 1 ; mark that text was found
return
}
return ; nothing was found, all is done
Could somebody point me in the right direction? Any help would be appreciated. Which commands are necessary when opening / re-reading the file, how to tell the program where it should be read, how to search for the text, all this in to say the least unclear to me.
Thank you.
--=kallera=--