![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | select-string to act like grep -v Does anyone know how to use select-string to print out everything except some string. ie. grep -v dontwantstring file.txt. Thanks in advance, |
My System Specs![]() |
| | #2 (permalink) |
| | Re: select-string to act like grep -v Here is my Text file: 1) This is a test 2) To see if I can do grep -v 3) with select string Test If you want to use select-string you can use the ! operator 48# cat mytext.txt | select-string "test" 1) This is a test 3) with select string Test 49# cat mytext.txt | ?{!($_ | select-string "test")} cat mytext.txt | ?{!($_ | select-string "test")} I am sure there is an easier way to accomplish what you want, but I am on the bus ATM and cant poke around much. "Frank" <Frank@discussions.microsoft.com> wrote in message news:160AA7EC-722B-4CA5-A64D-B29F51465CAA@microsoft.com... > Does anyone know how to use select-string to print out everything except > some > string. ie. grep -v dontwantstring file.txt. > > Thanks in advance, > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: select-string to act like grep -v On May 11, 11:28 pm, Frank <F...@discussions.microsoft.com> wrote: > Does anyone know how to use select-string to print out everything except some > string. ie. grep -v dontwantstring file.txt. > > Thanks in advance, If you mean literally everything except the string, then this seems quicker: (cat file.txt) - replace "dontwantstring" -Hecks |
My System Specs![]() |
| | #4 (permalink) |
| | Re: select-string to act like grep -v "Frank" <Frank@discussions.microsoft.com> wrote in message news:160AA7EC-722B-4CA5-A64D-B29F51465CAA@microsoft.com... > Does anyone know how to use select-string to print out everything except > some > string. ie. grep -v dontwantstring file.txt. It might be nice if Select-String supported a -NotMatch parameter but it doesn't. So I would do this: PS> gc file.txt | ?{$_ -notmatch 'dontwantstring'} -- Keith |
My System Specs![]() |
| | #5 (permalink) |
| | Re: select-string to act like grep -v On May 12, 5:25 am, "Keith Hill [MVP]" <r_keith_h...@no.spam.thank.u.hotmail.com> wrote: > "Frank" <F...@discussions.microsoft.com> wrote in message > > news:160AA7EC-722B-4CA5-A64D-B29F51465CAA@microsoft.com... > > > Does anyone know how to use select-string to print out everything except > > some > > string. ie. grep -v dontwantstring file.txt. > > It might be nice if Select-String supported a -NotMatch parameter but it > doesn't. So I would do this: > > PS> gc file.txt | ?{$_ -notmatch 'dontwantstring'} > > -- > Keith But again that will only return the lines that don't contain the string, is that what the OP wants? Using the example above, (gc file.txt) -replace "test" will return: 1) This is a 2) To see if I can do grep -v 3) with select string -Hecls |
My System Specs![]() |
| | #6 (permalink) |
| | Re: select-string to act like grep -v <hecks@hotmail.co.uk> wrote in message news:1178945469.398505.130210@k79g2000hse.googlegroups.com... > > But again that will only return the lines that don't contain the > string, is that what the OP wants? Using the example above, (gc > file.txt) -replace "test" will return: > > 1) This is a > 2) To see if I can do grep -v > 3) with select string I think so. The definition of grep -v is: -v displays all lines not matching a pattern. -- Keith |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Select-String -exclude | PowerShell | |||
| select-string substitute | PowerShell | |||
| problems with $var | select-string -pattern $string -q | PowerShell | |||
| Re: select-string exceptions | PowerShell | |||
| select-string question | PowerShell | |||