Re:Microsoft Replaces Command Prompt with PowerShell in Late...
by jodrellblank on Friday November 18, 2016 @12:43PM
(#12988497)
'troll' * 1000 > out.txt
Open in NotePad++, no weird newlines in the wrong place, content not truncated.Were you using |format-table and |format-list (ft, fl) to explicitly format the text for console viewing, then redirecting that to a file?
Re:Microsoft Replaces Command Prompt with PowerShell in Late...
by pjc50 on Friday November 18, 2016 @01:54PM
(#12989135)
Took a while to reproduce the actual case, and it's Select-String that's at fault. And it must be in "powershell" not "powershell ISE".
'troll' * 1000 > troll.txt
.. works fine as you say Select-String -Path .\troll.txt -Pattern "t" > t.txt
.. wraps the output at the console width. Which means you can't use it as a grep replacement.
Re:Microsoft Replaces Command Prompt with PowerShell in Late...
by jodrellblank on Friday November 18, 2016 @02:27PM
(#12989397)
You can't use it as grep in bash, because it isn't that. It outputs [MatchInfo] objects, not text, and Out-File (>) formats complex objects for console viewing (for ??? reasons), which is one reason > isn't a great PS habit.
Select-String -Path .\troll.txt -Pattern "t" | Set-Content t.txt
or
sls 't' .\troll.txt | sc t.txt
Re:Microsoft Replaces Command Prompt with PowerShell in Late...
by new_hackers on Friday November 18, 2016 @10:37AM
(#12987433)
this ^^^
This is the main reason I still use cmd.exe
I bet it still truncates output of the ">" operator to the console width, too.