Tech Support Guy banner
Status
Not open for further replies.
1 - 4 of 4 Posts

·
Registered
Joined
·
86 Posts
Discussion Starter · #1 ·
Hi all,

Is there an easy way to extract the entire line in a simple text file
that contains a "keyword" into another file.

For example:

"16/02/2004"," 8:47 AM","Added","EXAMPLE","141607","Bob Builder"
"16/02/2004","10:17 AM","Added","EXAMPLE","140235","Pat Boone"
"16/02/2004","10:47 AM","Added","EXAMPLE","140069","Donald Duck"
"16/02/2004","10:47 AM","Added","EXAMPLE","140563","Robert Rose"
"16/02/2004","10:47 AM","Added","EXAMPLE","140728","James Bond"
"16/02/2004","10:47 AM","Added","EXAMPLE","140751","Nicholas Brown"

If I wanted to extract the entire line with "140069" in it.

Thanks for any help
 

·
Registered
Joined
·
2,438 Posts
Using what tigsboy? Is this to be done by writing an app using Java or C++? Or if that hasn't been decided or is overkill what environment is the whole thing set in?

If you can tell us how you need it approached I'm sure someone will be able to offer a solution. :)
 

·
Registered
Joined
·
86 Posts
Discussion Starter · #3 ·
Sorry for the lack of detail. It is a Win2000 system. A simple batch file or Jscript would be fine. We have a log file and simply want to extract the whole line with specified keywords.
Thanks
 

·
Registered
Joined
·
53 Posts
@echo off
rem get the 5 parameters looking for "@" which should not exist
rem any character not in the lines will do
rem this gets the comma's as well it thats what you want
rem if you don't want the comma use "delims=,"
rem This is one line
rem Usage: FileName TextToFind
for /f "tokens=1-5 [email protected]" %%a in (tmp.txt) do echo %%a %%b %%c %%d %%e | find "%1" >> x.txt
 
1 - 4 of 4 Posts
Status
Not open for further replies.
Top