Script to find count of a string in a .cvs file - Powershell

Posted on 2010-09-13
Last Modified: 2012-05-10
I need to write a script to scan a group of .csv files and return a total of lines a specific string occurs on.

Preferably Powershell.
Question by:someITGuy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

wmehardt earned 500 total points
ID: 33664949
(gci *.csv | select-string "<string here>" | measure-object).count

Author Comment

ID: 33665250
Are the brackets ( )  in the correct place?

Assisted Solution

wmehardt earned 500 total points
ID: 33665501
Yup, are you having issues? What is the string you are looking to match? You can also do it this way with no parentheses

Select-String -path c:\folder\*.csv -pattern "string" | measure-object | select count

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question