Solved

in batch "findstr /e" does not recognize eol

Posted on 2006-06-27
2
1,355 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-
[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 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Windows Batch Script to Delete Time-Stamped Folders 3 110
How can I save all open docs into a given folder 12 128
Command prompt output to variable? 9 75
how to export this list 4 83
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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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