Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get-Content String Pattern Matching Using CSV File

80 views
Skip to first unread message

matekus

unread,
Mar 15, 2010, 1:08:02 PM3/15/10
to
get-content .\today_all.txt | select-string -pattern '\(' -notmatch |
select-string 'Alpha', 'Bravo', 'Charlie' -simplematch | set-content
.\today_filter.txt

I would like to replace the specific strings ('Alpha', 'Bravo', 'Charlie')
in the above command line with a simple text file so that additional filters
can be added without having to change the command itself:
filters.csv
Filter
Alpha
Bravo
Charlie
...

Please advise?

matekus
--
Illiud Latine dici non potest

Larry__Weiss

unread,
Mar 15, 2010, 1:47:49 PM3/15/10
to
Try

get-content .\today_all.txt | select-string -pattern '\(' -notmatch |

select-string (Get-Content filters.csv) -simplematch | set-content
.\today_filter.txt

- Larry

matekus

unread,
Mar 15, 2010, 9:58:01 PM3/15/10
to
Thanks Larry.

Your solution worked perfectly.

matekus
--
Illiud Latine dici non potest


"Larry__Weiss" wrote:

> Try
>
> get-content .\today_all.txt | select-string -pattern '\(' -notmatch |
> select-string (Get-Content filters.csv) -simplematch | set-content

> ..\today_filter.txt


>
> - Larry
>
> matekus wrote:
> > get-content .\today_all.txt | select-string -pattern '\(' -notmatch |
> > select-string 'Alpha', 'Bravo', 'Charlie' -simplematch | set-content
> > .\today_filter.txt
> >
> > I would like to replace the specific strings ('Alpha', 'Bravo', 'Charlie')
> > in the above command line with a simple text file so that additional filters
> > can be added without having to change the command itself:
> > filters.csv
> > Filter
> > Alpha
> > Bravo
> > Charlie
> > ...
> >
> > Please advise?
> >
> > matekus

> .
>

0 new messages