Powershell is an open-source, cross-platform shell and scripting language. It is built on top of Microsoft’s .NET
framework.
A shell in Computer Science is a user interface that allows interaction with the operating system.
Like any other language, Powershell has its commands and syntax. We will be discussing `n, as used in Powershell.
`n is used in Powershell to append a new line to the standard output.
The use of `n in Powershell is similar to \n in C++ or Java.
The backtick character (`) represents an escape character in Powershell.
An escape character lets us print otherwise unprintable characters to the standard output.
The purpose of escape characters is to represent whitespace characters like: \t
(tab), \n
(newline), and \r
(carriage return). An escape character can be prefixed to a special character to convert into an ordinary character.
Note: Powershell can only interpret escape characters when enclosed within double quotes (
" "
).
Write-Host "``n"
# prints the newline char (`n) as an ordinary character
Write-Host "Hello`nWorld"
#prints Hello World separated by a new line.
`n
Hello
World
Try the above code in the terminal below to see the command in action and produce the result.