Here is a poweshell example

get-content c:\test.txt | Where {$_ -notmatch "OK"}




On Wed, Oct 26, 2011 at 7:15 AM, Rankin, James R <[email protected]>wrote:

> You could probably strim a load of useless crap out of batch files I have
> been using and re-using for years. Hopefully my PowerShell will be less
> unnecessarily bloated :-)
>
> ------Original Message------
> From: Ben Scott
> To: NT System Admin Issues
> ReplyTo: NT System Admin Issues
> Subject: Re: Show lines in a text file that DONT contain OK
> Sent: 26 Oct 2011 12:06
>
> On Wed, Oct 26, 2011 at 4:07 AM, James Rankin <[email protected]>
> wrote:
> > type textfile.txt | find /c "OK"
>
>  In the Unix world, we have something called "useless use of cat".  I
> guess in the NT world, we have "useless use of TYPE".  :-)
>
>  FIND can accept a filename as an argument.  There's no need to
> invoke TYPE and pipe the output.
>
>        FIND /C "OK" textfile.txt
>
>  If something can only read standard input, you're better off using
> input redirection, e.g.:
>
>        FIND /C "OK" < textfile.txt
>
> Or, if you prefer your input file first on the command line:
>
>        < textfile.txt FIND /V /C "OK"
>
>  Invoking TYPE and piping means a buffer or temporary file is
> allocated, the input file is spooled into that, and then the buffer is
> fed into the next program.  In a small file it doesn't really matter,
> but on a big file it's rather inefficient.  Giving a file argument, or
> re-assigning standard input, means the file is just read.  :)
>
> -- Ben
>
> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~
>
> ---
> To manage subscriptions click here:
> http://lyris.sunbelt-software.com/read/my_forums/
> or send an email to [email protected]
> with the body: unsubscribe ntsysadmin
>
> Sent from my SR-71 Blackbird
> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~
>
> ---
> To manage subscriptions click here:
> http://lyris.sunbelt-software.com/read/my_forums/
> or send an email to [email protected]
> with the body: unsubscribe ntsysadmin
>

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin

Reply via email to