rojcasca
(Lurker)
2003-09-04 04:15 PM
Find string in a file

Hi,

I'm new with Kix, this is my question:

I'need found a string in a specific file, i don't find any command.

Please Help me.

Thank You


Radimus
(KiX Supporter)
2003-09-04 04:21 PM
Re: Find string in a file

be more specific.

do you need to replace a string?
do you need only to find if it is present?
do you need to return the string?


rojcasca
(Lurker)
2003-09-04 04:24 PM
Re: Find string in a file

Sorry,

I need find If the string is present in a file


Radimus
(KiX Supporter)
2003-09-04 04:37 PM
Re: Find string in a file

see this link

http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=007764


rojcasca
(Lurker)
2003-09-05 11:48 AM
Re: Find string in a file

Hi Radimus,

I don't understand the URL what it's the command to find string in a file?.


Radimus
(KiX Supporter)
2003-09-06 12:29 AM
Re: Find string in a file

you can't find it in a file, you have to read the file and then do an instr() on each line

Richard H.Administrator
(KiX Supporter)
2003-09-05 01:00 PM
Re: Find string in a file

Alternatively, if you just want to check if the string is in the file, used the DOS "FIND" command.

For example:
code:
FIND /I "string" myfile.txt

Will search myfile.txt for "string".

The exit code will be "0" if the string is present, and "1" if it is not.

In KiXtart you can "Shell" the command and check @ERROR or %ERRORLEVEL%


Sealeopard
(KiX Master)
2003-09-17 11:40 PM
Re: Find string in a file

See also the following UDF: IsStringInFile() - Checks whether a string is present in a file