Extract line containing a keyword fro text file

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

tigsboy

Thread Starter
Joined
Nov 25, 2001
Messages
86
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
 
Joined
Nov 24, 2002
Messages
2,438
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. :)
 

tigsboy

Thread Starter
Joined
Nov 25, 2001
Messages
86
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
 
Joined
Jan 31, 2003
Messages
53
@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
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top