Solved

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

Posted on 2014-04-16
4
244 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 84

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 54

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 84

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Batch File - pass parameter with embedded space 7 44
I am new to using JSON in SQL Server 2 59
Cannot get group page break to work in SSRS 2008R2. 14 40
SQL query 45 41
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…

752 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