Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Output to a separate file all lines containing a string *ERROR

Posted on 2014-04-16
4
Medium Priority
?
247 Views
Last Modified: 2014-04-16
I want to pull out all lines in a txt file that contain *WARNING and otput to a separate txt file. Want to use Batch. Please help
0
Comment
Question by:LuckyLucks
  • 2
4 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 1000 total points
ID: 40004256
A simple "find" will do the trick:
type "SomeFile.txt" | find /i "*WARNING" >"SeparateFile.txt"

Open in new window

If you want to add to the separate file instead of overwriting it, use double ">":
type "SomeFile.txt" | find /i "*WARNING" >>"SeparateFile.txt"

Open in new window

0
 

Author Comment

by:LuckyLucks
ID: 40004453
type is not a command , you are just describing what needs to be typed, right?
0
 
LVL 59

Assisted Solution

by:Bill Prew
Bill Prew earned 1000 total points
ID: 40004557
TYPE actually is a command, it reads a file and displays it to standard output.

You can actually do the same thing slightly simpler as:

find /i "*WARNING" <"SomeFile.txt" >"SeparateFile.txt"

~bp
0
 
LVL 85

Expert Comment

by:oBdA
ID: 40004903
"type" is a regular command; I use it to avoid the separator line(s) that appears when using find "something" file.exe I find it easier to read than redirecting the output like billprew suggested.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question