read line using select string until . character found
<p>I am facing a problem on PowerShell reading line. My requirement is : </p>

<p><strong>using select string, if a pattern found, than read line until "." is found and show the output in one line.</strong></p>

<p>My file looks like that:</p>

<pre><code> file: this is the first 
 file for
 read.
 error:this is the error.
 data: this is the data.
 file: this is the 
 second file.
</code></pre>

<p>In the file, if "file" is found, than read the full line until next "." is found. Because the line is truncated.</p>

<p>Desired Output is:</p>

<pre><code>file: this is the first file to read.
file: this is the second file.
//file name will be removed before
</code></pre>

<p>I try like:</p>

<pre><code> $totalFile = Select-String *.log -pattern "file:" -CaseSensitive -Context 0,1| % {$_.line}| Out-File "result.txt"
</code></pre>

<p>But context is not working because some file is in 2 line some are in 3 line. And also output is not showing in one line.</p>