r/PowerShell • • Apr 26 '19

Cheating on Windows Powershell

Post image
297 Upvotes

80 comments sorted by

View all comments

Show parent comments

5

u/ka-splam Apr 27 '19

4.7GB logfile, 55 Million lines, most of them repeated that I wanted to strip out:

PowerShell attempt 1: 12 hours, 12GB RAM, didn't finish.

PowerShell, attempt 2: 45 minutes.

Git Bash attempt 1: 9.5 seconds


PS1

PS C:\> (gc vmware.log) -notmatch 'GuestRpc: Channel \d' | sc vmware2.log

PS2

PS C:\> measure-command { 
    gc .\vmware.log -ReadCount 1000 |%{$_}|
    ?{ $_ -notmatch 'GuestRpc: Channel'} |
    ?{ $_ -notmatch' toolbox-dnd'} | 
    set-content vmware3.log 
}

Days              : 0
Hours             : 0
Minutes           : 44
Seconds           : 45

Git Bash:

$ time cat vmware.log | grep -v 'GuestRpc: Channel' | grep -v 'toolbox-dnd' > vmware4.log

real    0m9.633s

2

u/[deleted] Apr 27 '19

That... Not how I would do that in powershell... 🙄

2

u/ka-splam Apr 28 '19 edited Apr 28 '19

How would you do it?

1

u/[deleted] Apr 29 '19

Select-String -Path vmware.log -Pattern 'GuestRpc: Channel \d' -NotMatch | Out-File vmware2.log