Assuming a file called "test.txt" ... To get the number of lines ending in Y, you can do this:
get-content test.txt | select-string Y$ | measure-object -line
And to get the number of lines ending in N, you can do this:
get-content test.txt | select-string N$ | measure-object -line
Hope this helps.
source
share