DonationCoder.com Forum

Main Area and Open Discussion => General Software Discussion => Topic started by: kalos on September 23, 2013, 04:55 PM

Title: extract lines containing
Post by: kalos on September 23, 2013, 04:55 PM
hello
can you tell me please how to search inside a bunch of text files and "extract'' all the lines that contain *something* in a list into a new text file?
thanks!
Title: Re: extract lines containing
Post by: AndyM on September 23, 2013, 07:43 PM
from a command line you can issue the Find command and redirect the results to a text file

if you want to use wildcards I think you have to use the Find command inside a For statement

look up Find, For, and redirecting output in a Command Line reference
Title: Re: extract lines containing
Post by: x16wda on September 23, 2013, 07:45 PM
qgrep -y findme *.txt > results.txt

That's on a Windows platform with qgrep (from one of the old resource kits).  The -y means case insensitive, findme is the string to find (you could look for multiple words with "one two" instead, it will find lines with either), you're searching through all the .txt files and directing the output to a file.

Of course there are more options with a real grep, depending on your platform.
Title: Re: extract lines containing
Post by: 4wd on September 24, 2013, 12:19 AM
grepWin (http://stefanstools.sourceforge.net/)

[ You are not allowed to view attachments ]

1) Directory
2) Text search
3) Text to search for
4) File filter
5) Select to display Content

When it's finished, select all the results and copy to clipboard, you can then paste them into a file.
Title: Re: extract lines containing
Post by: AbteriX on September 24, 2013, 01:11 AM
from a command line you can issue the Find command and redirect the results to a text file

if you want to use wildcards I think you have to use the Find command inside a For statement

look up Find, For, and redirecting output in a Command Line reference

Nowadays we even have 'findstr' on Win7:

FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P]
        [/F:Datei] [/C:Zeichenfolge] [/G:Datei] [/D:Verzeichnisliste]
        [/A:Farbattribute] [/OFF[LINE]] Zeichenfolgen
        [[Laufwerk:][Pfad]Dateiname[ ...]]
http://ss64.com/nt/findstr.html


C:\>FindStr /R myregexsearchpattern C:\Temp\*.txt > C:\Temp\results.txt


- - -

hehehe, the circle closes   :P :

Along the way, qgrep somehow changed its name to findstr.
http://blogs.msdn.com/b/oldnewthing/archive/2012/11/28/10372436.aspx
.
Title: Re: extract lines containing
Post by: David1904 on September 25, 2013, 04:42 PM
Available on TUCOWS

TextHarvest 3.00.00
file size: 696.39 KB

As TextHarvest copies a text file it can keep, delete, skip, edit or reformat lines that contain specified strings of text.
Title: Re: extract lines containing
Post by: saralynn on October 24, 2013, 05:25 PM
TextPad has a "Find in Files" command that lets you search content of files within your specified path.
Search pattern can be a regular expression & you can limit which type(s) of files are searched.
Although it doesn't directly export the search results to a new file, you can easily SaveAs the results output.
(you'll probably first want to search/replace to remove the filename+lineNumber from start of each line)
Title: Re: extract lines containing
Post by: ur1sn00per on December 16, 2013, 04:58 PM
http://textmechanic.com/ online text manipulation tool
Title: Re: extract lines containing
Post by: alandavid on December 17, 2013, 12:57 AM
grepWin (http://stefanstools.sourceforge.net/)
 (see attachment in previous post (https://www.donationcoder.com/forum/index.php?topic=36193.msg338569#msg338569))
1) Directory
2) Text search
3) Text to search for
4) File filter
5) Select to display Content

When it's finished, select all the results and copy to clipboard, you can then paste them into a file.
Thanks for share such a good information. i am new in this but now i got it.