Solved

in batch "findstr /e" does not recognize eol

Posted on 2006-06-27
2
1,349 Views
Last Modified: 2012-05-05
Hi,

I want to use the "findstr /v /e" command to list lines in a file that end (or don't end) with a certain combination. If I create the file (lets call it myfile.txt) manually and type in the following two lines,

abc000
dec001

and then run (findstr /e "000" myfile.txt), it displays abc000
and if i run   (findstr /e /v "000" myfile.txt), it displays dec001

But if I create myfile.txt like below,

echo abc000 >> myfile.txt
echo dec001 >> myfile.txt

(findstr /e "000" myfile.txt) does not give an output
(findstr /e /v "000" myfile.txt) displays both lines as if neither line ended with 000

Any help on why this happens and how to overcome the problem would be appreciated.
0
Comment
Question by:TAI-
2 Comments
 
LVL 28

Accepted Solution

by:
Michael Pfister earned 250 total points
ID: 16992344
Change the above to

echo abc000>> myfile.txt
echo dec001>> myfile.txt

and it will work. Note that the is NO blank between the line to be echoed and the >>. The file created by your example had an invisible blank after the numbers, therefore the strange output.

Hope it helps,

Michael

0
 

Author Comment

by:TAI-
ID: 16998855
I was suspecting the end of line spaces. But interestingly removing them manually with "find and replace" doesn't work.

Also you have to be careful if you generate a file with ">>" using the contents of an existing file. If the source file has eol spaces, the resulting file will also have spaces even you use >> without spaces. Thank you for the reply.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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