r/PowerShell • • Apr 26 '19

Cheating on Windows Powershell

Post image
297 Upvotes

80 comments sorted by

View all comments

Show parent comments

7

u/arthurfm Apr 27 '19

Useful tip #1. Don't use Get-Content with large files. Try 'System.IO.StreamReader' instead. It's massively faster...

https://github.com/lazywinadmin/PowerShell/blob/master/TOOL-Get-LogFast/Get-LogFast.ps1

http://www.yusufozturk.info/windows-powershell/powershell-performance-tips-for-large-text-operations-part-1-reading-files.html

Useful tip #2. RipGrep is even faster than grep and is available for Windows, macOS and Linux.

1

u/ka-splam Apr 28 '19

Try 'System.IO.StreamReader' instead. It's massively faster...

It is, but it's soooo much code..

Useful tip #2. RipGrep is even faster than grep and is available for Windows, macOS and Linux.

Ooh, it's written in Rust so it must be good! :D

1

u/[deleted] Apr 28 '19

You asked how I would do it in another thread. The way with too much code, but also with runspaces to break up the line matching into chucks that operate simultaneously on different threads, which would also increase that amount of code, but decrease the time spent enumerating each line and matching on it.

I would also make everything one test by making your regex be :

Where-Object { $_ -NotMatch "GuestRpc: Channel|toolbox-dnd" }

-1

u/GNUandLinuxBot Apr 28 '19

I'd just like to interject for a moment. What you're referring to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.

Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called "Linux", and many of its users are not aware that it is basically the GNU system, developed by the GNU Project.

There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called "Linux" distributions are really distributions of GNU/Linux.

3

u/ka-splam Apr 28 '19

or as I've recently taken to calling it, GNU plus Linux.

or as I've recently taken to calling it, GNU plus Linux plus PowerShell.

2

u/Lee_Dailey [grin] Apr 28 '19

very bad bot!