Solved

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

Posted on 2010-09-13
3
626 Views
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.
0
Comment
Question by:someITGuy
  • 2
3 Comments
 
LVL 4

Accepted Solution

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

Author Comment

by:someITGuy
ID: 33665250
Are the brackets ( )  in the correct place?
0
 
LVL 4

Assisted Solution

by:wmehardt
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
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
This article will help you understand what HashTables are and how to use them in PowerShell.
The viewer will learn how to count occurrences of each item in an array.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

930 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now