Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 145 Vote(s) - 3.59 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inserting blank lines in powershell console

#1
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.
Reply

#2
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
Reply

#3
Best way to do blank lines for me is :

""


If you write that in script or console you get a blank line, just two double quotes.

If you want to create for example 3 new blank lines in one shot you could do :

"" ; "" ; ""
Reply

#4
Write-Host " "

I just copy this and keep it in clipboard to easily create empty spaces in my script presented to console.

I believe this is what he was looking for, This enables him to use the paste hotkey to easily accomplish his goal of keeping his output console run script clean by creating a fake space with that line.

Reply

#5
write-host `n"hello"

the output is:

>hello

This works because `n is a special character sequence, which represents a newline, in PowerShell.

Simply follow the link/URL below, for additional information regarding the use of special characters, in PowerShell.

<b>Microsoft PowerShell Documentation - About Special Characters:</b>

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through