-2

I need to use findstr command without new line.

My file "prova.txt" contains:

La#
Do#
Fa#

My batch file contains:

@echo off
FINDSTR Do# prova.txt

The result of command is:

Do#
//second empty line

Instead I wish it was:

Do#

How do I get this?

I Explain better:

I don't want the new line (the Enter keys) after the findstr command.

  • You mean you do not want the trailing new-line? – aschipfl Oct 23 '16 at 11:09
  • *every* command (nearly) gives you a trailing empty line. Do you have a special problem with it? You *could* write a script for output without that empty line, but I doubt, it is worth it, execpt you have a special need for it. – Stephan Oct 23 '16 at 12:27
  • What are you trying to do ? Whats the finallity of your code ? – SachaDee Oct 23 '16 at 15:11
  • There isn't a magical, _(unless you use the appropriate shell)_, echo -n solution. The long winded NT command script solution would require a real task with real strings and a genuine end product. – Compo Oct 23 '16 at 16:00
  • exactly @aschipfl – Riccardo La Marca Apr 12 '18 at 18:54
  • @SachaDee I don't want the new line (the Enter keys) after the findstr command. – Riccardo La Marca Apr 12 '18 at 19:57
  • @Stephan, in general you are right in your comment, except for the terminology: a trailing new-line (or end-of line) marker is not an empty line; you have got an empty line only when there are no characters between a previous new-line (or the beginning of a string/file) and the next one; so to have got an empty line at the end of a string/file you need to have two consecutive new-lines at the end... – aschipfl Apr 15 '18 at 19:38

1 Answers1

2

I don't anderstand what you're trying to do. But try like this :

@echo off

for /f "delims=" %%a in ('FINDSTR "Do#" "prova.txt"') do echo|set /p="%%a"
echo.
SachaDee
  • 9,245
  • 3
  • 23
  • 33