Tuesday, June 1, 2010

More powershell

Here's what I wrote today:


1. Get-Item count.txt | Get-Content | Measure-Object -Line | Select-Object -ExpandProperty Lines
2. Get-Item count.txt | Get-Content | Select-String -Pattern "ThatObject\.Load\(\)" | Measure-Object -Line

In one, note the -ExpandProperty option. This returns an integer rather than a powershell object containing an integer.

In two, note the use of a regular expression.

Regular expressions are cool in general, but my regular expression skills and my powershell skills suffer from the same problem, and that is that I tend to use them rarely. But they're very useful when I do use them. When I get to combine the two, that's just a bonus.

No comments:

Post a Comment