Solved

in batch "findstr /e" does not recognize eol

Posted on 2006-06-27
2
1,325 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
Comment Utility
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-
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

13 Experts available now in Live!

Get 1:1 Help Now