Currently in PowerShell the echo command always append a newline. What would be the equivalent for the Unix echo -n ?
Currently in PowerShell the echo command always append a newline. What would be the
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
echois an alias forWrite-Outputwhich sends objects to the next command in the pipeline. If all you want to do is display text on the console you can do:Write-Host "Hi" -NoNewLineKeep in mind that this is not the same cmdlet as echo|Write-Output.
Write-Output‘s primary purpose is send objects to the next command in the pipeline whereWrite-Host‘s primary purpose is to display text on the console. The reason why you see text on the console usingWrite-Outputis that the PowerShell engine sends everything toOut-Defaultat the end of the pipeline which sends the incoming to PowerShell’s object to text formatting engine.Here is an example:
This will produce an error because
Write-Hostjust writes the text to the console and doesn’t forward the string to the next command in the pipeline.This will display the
System.Stringproperties and methods becauseWrite-Outputsends thestringobject to the next object in the pipeline.Write-Host: http://technet.microsoft.com/en-us/library/dd347596.aspxWrite-Output: http://technet.microsoft.com/en-us/library/dd315282.aspx