Page 1 of 1
Extra 'Space' character in FOR-Pipe construction
Posted: 13 Jun 2014 05:25
by Dragokas
Hi !
I write this code to extract from all txt files the lines with 2 or more '.' character.
Code: Select all
@(for %a in (*.txt) do @(type %a& echo.)) | find ".." > new.txt
All files have 1 string (no CrLf).
That's why I use 'echo.'
But new.txt have an extra 'space'-character on the end of each line.
Can someone explain why?
The code:
Code: Select all
@(for %a in (*.txt) do (echo ..)) | find ".."
Result:
(echo .. )
2 spaces after '..'
Re: Extra 'Space' character in FOR-Pipe construction
Posted: 13 Jun 2014 06:13
by Squashman
did you try removing the spaces before and after the PIPE and redirection characters
Re: Extra 'Space' character in FOR-Pipe construction
Posted: 13 Jun 2014 08:06
by Dragokas
Yea, the result is same.
Re: Extra 'Space' character in FOR-Pipe construction
Posted: 13 Jun 2014 08:32
by foxidrive
There is a thread here which discusses the pipe and errant spaces.
Re: Extra 'Space' character in FOR-Pipe construction
Posted: 13 Jun 2014 08:34
by foxidrive
Try this:
Code: Select all
for %a in (*.txt) do find ".." < "%a" > new.txt
You might have to show us some of your data if it needs extra processing.
Re: Extra 'Space' character in FOR-Pipe construction
Posted: 13 Jun 2014 08:49
by Squashman
foxidrive wrote:Try this:
Code: Select all
for %a in (*.txt) do find ".." < "%a" > new.txt
You might have to show us some of your data if it needs extra processing.
I was just going to suggest that because I could not understand why he was using the echo and pipe.
Re: Extra 'Space' character in FOR-Pipe construction
Posted: 13 Jun 2014 08:57
by einstein1969
Dragokas wrote:Hi !
I write this code to extract from all txt files the lines with 2 or more '.' character.
Code: Select all
@(for %a in (*.txt) do @(type %a& echo.)) | find ".." > new.txt
All files have 1 string (no CrLf).
That's why I use 'echo.'
But new.txt have an extra 'space'-character on the end of each line.
Can someone explain why?
The code:
Code: Select all
@(for %a in (*.txt) do (echo ..)) | find ".."
Result:
(echo .. )
2 spaces after '..'
The space in output is only one.
This explain why.
You can produce no space using:
einstein1969
Re: Extra 'Space' character in FOR-Pipe construction
Posted: 13 Jun 2014 09:01
by Squashman
So he is trying to concatenate the output all onto one line in the output file?
Re: Extra 'Space' character in FOR-Pipe construction
Posted: 13 Jun 2014 09:20
by foxidrive
I get the impression that his data is a single line in a bunch of text files.