In bash script the backslash is use as escape sequence and even in Java programming.
But what's the equivalent of bash escape sequence in PowerShell?
Grave accent or back tick, which is found at the top left corner of the keybord below the "esc" key on some keyboard, This character "`" is the escape in PowerShell.
For example:
Write-host "This line is above `r`n and `r`n this line is below"
Output is:
This line is above
and
this line is below
r is equal to carriage return character putting a backtick before r, `r tells PowerShell that r is not a character but a carriage return
n is a new line character putting a backtick before n, `n tells PowerShell that n is a new line character.
Another example:
$ sign in PowerShell is to indicate a variable
But what if you need to display a dollar sign as a character and not as a special character to declare a variable. Then we need to escape the dollar sign by prefixing a backtick before the character.
Example:
write-host "The i-gadget is expensive it cost `$1500. OMG!"
Check out this MSDN link: About special characters - PowerShell
Cheers! Till next time.
================================
Free Android Apps:
Click on links below to find out more:
Linux Android App cheat sheet:
Multiplication Table for early learners
Catholic Rosary Guide for Android:
Divine Mercy Chaplet Guide (A Powerful prayer):
Comments
Post a Comment