On unix I can do a
tail -f file
And the equivalent powershell command is
gc file -Wait
However on unix I can press enter to add some blank lines (for readability) on the console while it is outputting lines, but not in powershell. Any workaround?
Use case: On unix I run tail -f /some/webserver/log/file
and it outputs the last part of the log. I then do some http-requests and the log scrolls by accordingly. I then press enter a couple of times to get some blank space in the console, so the log entry for the next request stands out because of the blank lines above.
You can use `n to create a new line .
This is just a small example , if you want to modife the out put of the Get-Content command you should store the out put and then and the new line to line 10 for example then retrieve the out put.
write-host "This is an example"
write-host "`n"
write-host "just to show how to add a new line"
This example reads a file and when it get to line to in inserts a space.
$content = Get-Content C:\Dump\test.txt
foreach ($line in $content)
{
if ($line.ReadCount -eq 2) { Write-Host "`n$line" }
Else{$line}
}
This is the out put
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7