$ORS(output record separator) variable like awk's ORS for more flexible output - by S.K. _

Status : 

 


2
1
Sign in
to vote
ID 773209 Comments
Status Active Workarounds
Type Suggestion Repros 0
Opened 12/1/2012 8:35:20 PM
Access Restriction Public

Description

Now powershell has $OFS(output field separator) but don't have "output record separator" like awk's ORS.
So when we don't want to start a new line with all lines, we have to use Write-Host -NoNewline.
Or, when we want to start a new line twice with a record, we have to add '`n' to all lines.

Eample

PowerShell > 1..5 # default record separator is '`n' 
1
2
3
4
5

PowerShell > $ORS = '' # no separator for records
PowerShell > 1..5
12345

PowerShell > $ORS = ',' # record separator is ','
PowerShell > 1..5
1,2,3,4,5

PowerShell > $ORS = "`n`n" # record separator is '`n`n'
PowerShell > 1..5
1

2

3

4

5
Sign in to post a comment.