![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | how to get rid of line wrapping in powershell PS C:\Temp> '-' * 200 >a.txt halfway correctly generates a line of 200 - and incorrectly adds an additional newline C:\Temp>powershell -command '-' * 200 >a.txt wraps the line into two lines. How can I get rid of these behaviors Harald |
My System Specs![]() |
| | #2 (permalink) |
| | RE: how to get rid of line wrapping in powershell You should probably check your results again. I can't reproduce this on my machine. I assume that your second command is actually: PS> powershell -command "'-' * 200 >b.txt" -- greetings dreeschkind "Harald Ums (2179630)" wrote: > PS C:\Temp> '-' * 200 >a.txt > halfway correctly generates a line of 200 - and incorrectly adds an > additional newline > C:\Temp>powershell -command '-' * 200 >a.txt > wraps the line into two lines. > > How can I get rid of these behaviors > > Harald > > |
My System Specs![]() |
| | #3 (permalink) |
| | RE: how to get rid of line wrapping in powershell You can use the .NET StreamWriter to avoid any additional newlines: $streamWriter = new-object System.IO.StreamWriter('C:\Temp\a.txt') $streamWriter.Write('-' * 200) $streamWriter.Close() $streamWriter.Dispose() -- greetings dreeschkind "Harald Ums (2179630)" wrote: > PS C:\Temp> '-' * 200 >a.txt > halfway correctly generates a line of 200 - and incorrectly adds an > additional newline > C:\Temp>powershell -command '-' * 200 >a.txt > wraps the line into two lines. > > How can I get rid of these behaviors > > Harald > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: how to get rid of line wrapping in powershell "Harald Ums (2179630)" <Harald_Ums@hotmail.com> wrote in message news:ORP8qIDtHHA.2164@TK2MSFTNGP02.phx.gbl... > PS C:\Temp> '-' * 200 >a.txt > halfway correctly generates a line of 200 - and incorrectly adds an > additional newline It's a usability trade-off, right? If you had to manually provide a newline for all output: "Hi there`n" "Here's another line`n" "And here's another`n" Then that would kind of suck. However I have been there, especially when outputting to a file, when you really don't want that last newline. It would be nice to have some control over that behavior. Perhaps something like: '-' * 200 | out-file -NoNewline a.txt -- Keith |
My System Specs![]() |
| | #5 (permalink) |
| | Re: how to get rid of line wrapping in powershell actually the command is c:\temp> powershell ./somescript >b.txt I wasn't clear enough: I ran powershell from a .cmd batch file (together with some other non-powershell scripts) As soon as the '>' is handled by cmd I get the wrapping So in a way you solved my problem: c:\temp> powershell "./somescript >b.txt" does not do any wrapping "dreeschkind" <dreeschkind@discussions.microsoft.com> wrote in message news:5C4DD432-1EBB-43F2-A297-6D68505909A3@microsoft.com... > You should probably check your results again. I can't reproduce this on my > machine. > I assume that your second command is actually: > PS> powershell -command "'-' * 200 >b.txt" > > -- > greetings > dreeschkind > > "Harald Ums (2179630)" wrote: > >> PS C:\Temp> '-' * 200 >a.txt >> halfway correctly generates a line of 200 - and incorrectly adds an >> additional newline >> C:\Temp>powershell -command '-' * 200 >a.txt >> wraps the line into two lines. >> >> How can I get rid of these behaviors >> >> Harald >> >> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Printing Single Line From Powershell | PowerShell | |||
| Text Line Wrapping | Vista mail | |||
| Line not wrapping in sent email | Vista mail | |||
| Wrapping PowerShell Scripts In A GUI Interface | PowerShell | |||
| Powershell.exe command-line syntax | PowerShell | |||