Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8908439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:10:43+00:00 2026-06-15T03:10:43+00:00

Please could someone give me a hand I’m sort of new to powershell so

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:10:44+00:00Added an answer on June 15, 2026 at 3:10 am

    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 ? ) :

    (gc c:\temp\tsts.txt |%{  $_.split(', ') -like 1 }|Measure-Object).count
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please give me a example of a function that would use this
Could someone please give me a link on how to create a query in
Could someone please explain why this is happening? var y = new int[]{1,2}; Console.WriteLine(y
Please could someone give me an example in batch of something like: IF test.txt
Could someone please give me some sample code that uses an output parameter in
Please could someone give me a few tips for creating function pointers for MS
Could someone please give me an example on how can I convert a byte[]
Could someone please give me some advice/ideas about how to deal with the situations
Could someone please give a list of all the applescript data types (the things
Could someone please give me a Perl example on how to load an image

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.