Solved

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

Posted on 2014-04-16
4
238 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 83

Accepted Solution

by:
oBdA earned 250 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 51

Assisted Solution

by:Bill Prew
Bill Prew earned 250 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 83

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now