Sometimes OO paradigm is an overhead, not a savior. Especially when it comes to simple manipulations such that are typical to shell scripting tasks. I mean, what appears more to the point and is faster to implement? This:
ipconfig | findstr "Address"
ifconfig | grep "Address"
The latter is more flexible, you can search for pretty much anything. And once you get regex involved — opportunities are endless.
As usual, instead of conforming to POSIX, Microsoft invents its own incompatible way of doing scripting. Sure, anything would seem to be better after horrors of COMMAND.COM and CMD.EXE. But it did not have to be that bad.
Maybe (quite certainly) I am biased, having spent years in a warm comfort of bash and tcsh. But maybe I am right and PShell is just another failed MSFT experiment at “borrowing” ideas from others…
I think what you want is:<BR/><BR/>(ipconfig) -match "address"<BR/><BR/>Match takes a regular expression so you can party to your hearts content.<BR/><BR/>Alternatively you can use simple wildcarding with -LIKE:<BR/><BR/>(ipconfig) -like "*addr*"<BR/><BR/>You can also use Select-String which takes a regular expression (which I always alias to "SS" and we’ll ship that alias in V2).<BR/><BR/>
Leave a comment