Please could someone give me a hand I’m sort of new to powershell so your patience and knowledge would very much be appreciated.
Here’s the problem: I have txt file with numbers on each line.
I need to Parse the txt file and find out how many times a specific value occurs
so in the example below I need to search the file for the value then count the number of occurrences
Example:
12,
2,
41,
234,
21,
1,
11,
1,
This is what I have tried so far
$txt = get-content 'C:\numbers.txt'
$search = $txt -match "1"
$search.count
But the results also find 12, 41, 21, 1, 11
How do I find out how to find the count of just 1?
I think you can split each line then use the -like operator instead of -match, with -like,both sides of the expression have to be the same, (but you can still use the usual wildcards * and ? ) :