Re: findstr output is garbled when the preceding files has no newline for the last line
- From: "Dean Wells [MVP]" <dwells@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 11 Sep 2005 10:04:00 -0400
I can confirm the behavior and would too consider it a bug. The
following syntax (when executed from within a script) will create
similar output to the native findstr command if that's what you really
need -
for %%l in (f1 f2) do @set /p =%%l:<nul&findstr "findstr" %%l&echo/
.... it is, however, less efficient on large numbers of files that
findstr alone. If this is not precisely what you're after, please post
back with an expanded definition of your goal.
Note, the FIND.EXE command does not exhibit this behavior but uses a
different output format.
--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
cliff wrote:
> hello,
>
> findstr output has a problem when the search word happens to be on a
> last line of the preceding file. The output will be garbled with the
> succeeding file searched.
> e.g here shows a sample command line session showing the problem with
> file1.txt and file2.txt :
>
> c:\ > type file1.txt
> test
> findstr
> c:\ > type file2.txt
> test
> findstr
> c:\ > findstr "findstr" file1.txt file2.txt
> file1.txt:findstrfile2.txt:findstr
>
>
> The desired output is :
> file1.txt:findstr
> file2.txt:findstr
>
>
> The last line should not have a newline for file1.txt. Try using
> notepad and make sure the last line does not have a newline. I also
> noticed that "edit" also seems to insert a newline for the last
> line(but not notepad).
> I also tested grep(a sort of findstr equivalent) and it does not have
> a this problem when given the same file1.txt and file2.txt.
>
> Will this problem be fixed? It could cause some subtle problems in
> scripts when pipes are used.
> This problem exists on Windows 2000 and Windows XP.
>
> regards,
> Cliff
.
- Follow-Ups:
- References:
- Prev by Date: Re: cmd prompt scrolls slowly
- Next by Date: Re: findstr output is garbled when the preceding files has no newline for the last line
- Previous by thread: findstr output is garbled when the preceding files has no newline for the last line
- Next by thread: Re: findstr output is garbled when the preceding files has no newline for the last line
- Index(es):
Relevant Pages
|