Solved

in batch "findstr /e" does not recognize eol

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 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