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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

821 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