Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-04-16
4
Medium Priority
?
246 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 57

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
In this article I will describe the Detach & Attach 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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

715 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