vendredi 5 mars 2021

Powershell - How to find and return different lines of a file with different patterns?

I am looking to find a way to return all the lines that match different patterns on different lines. For example the first line may contain the 2 following patterns: 25.2.2021 SET_ACCESS_GROUPS and another line may contain 25.2.2021 DELETE_GROUP

I tried different things such as the following but it does not seem to find any matches.

[String]$criteria1 = (25.2.2021+ ".*" + SET_ACCESS_GROUPS  + ".*")
[String]$criteria2 = (25.2.2021+ ".*" + DELETE_GROUP + ".*")

Get-Content $pathOrigin| Select-String -Pattern $criteria1,$criteria2| Set-Content $pathDestination

Aucun commentaire:

Enregistrer un commentaire