DOS FIND will not find some email addresses

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
r1ddl3m37h15
Posts: 1
Joined: 13 Jan 2014 12:30

DOS FIND will not find some email addresses

#1 Post by r1ddl3m37h15 » 13 Jan 2014 12:58

Can anyone explain why the find command is not working in the second example below.

A working example first.

Code: Select all

C:\temp>copy CON example1.txt
aa.aaa@aa.aaa^Z
        1 file(s) copied.

C:\temp>find /i "a" example1.txt

---------- EXAMPLE1.TXT
aa.aaa@aa.aaa

C:\temp>notepad example1.txt

This next example does NOT work.

Code: Select all

C:\temp>copy CON example2.txt
aa.aaa@a.aaa^Z
        1 file(s) copied.

C:\temp>find /i "a" example2.txt

---------- EXAMPLE2.TXT

C:\temp>notepad example2.txt

C:\temp>

Also, if you open example2.txt in notepad, it looks like junk. If you create the email address from the second example with notepad. The address is stored as hex "ffee610061002e006100610061004000 61002e00610061006100" not "aa.aaa@aa.aaa".

Can anyone explain why DOS thinks that "aa.aaa@aa.aaa^z" is a binary file?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: DOS FIND will not find some email addresses

#2 Post by foxidrive » 14 Jan 2014 01:12

r1ddl3m37h15 wrote:Can anyone explain why the find command is not working in the second example below.

Also, if you open example2.txt in notepad, it looks like junk. If you create the email address from the second example with notepad. The address is stored as hex "ffee610061002e006100610061004000 61002e00610061006100" not "aa.aaa@aa.aaa".

Can anyone explain why DOS thinks that "aa.aaa@aa.aaa^z" is a binary file?



The example2.txt file as created is fine, which you can prove with a hex editor/viewer.

Both example1.txt and example2.txt are created normally, and lack a CRLF on the end.
If you add a CRLF to the end of example2.txt it will behave as expected.

Here in Windows 8.1 the example2.txt file opens fine in Notepad but my usual editor tells me that it is a Unicode file - and this is the reason why it's failing I think.
In some manner, the pattern of hex digits are being interpreted as a unicode file.

Post Reply