ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

extract lines containing

(1/2) > >>

kalos:
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!

AndyM:
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

x16wda:
qgrep -y findme *.txt > results.txt

--- End quote ---

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.

4wd:
grepWin



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.

AbteriX:
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
-AndyM (September 23, 2013, 07:43 PM)
--- End quote ---

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.
--- End quote ---
http://blogs.msdn.com/b/oldnewthing/archive/2012/11/28/10372436.aspx
.

Navigation

[0] Message Index

[#] Next page

Go to full version