Solved

in batch "findstr /e" does not recognize eol

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

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