Jay_At_Play
Jay_At_Play

Reputation: 146

Ignore first line in FINDSTR search

I am searching an object-oriented Modelica library for a certain string using the following command in the Windows 7 PowerShell:

findstr /s /m /i "Searchstring.*" *.*

click for findstr documentation

The library consists of several folders containing text files with the actual code in them. To reduce the number of (unwanted) results, I have to ignore the first line of every text file.

Unfortunately, I cannot work out how to do this with the findstr command.

Upvotes: 0

Views: 1706

Answers (2)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200193

If you want to keep using findstr you could simply pipe the output into Select-Object:

findstr /s /m /i "Searchstring.*" *.* | select -Skip 1

Upvotes: 1

Paul
Paul

Reputation: 5861

You can use Select-String instead of findstr

To get all matches excluding the ones on the first line try something like this:

Select-String -Path C:\dir\*.* -pattern "Searchstring*" | where {$_.LineNumber -gt 1}

If you have to search subdirectories you can pair it with Get-Childitem:

Get-Childitem C:\dir\*.* -recurse | Select-String -pattern "Searchstring*" | where {$_.LineNumber -gt 1}

Upvotes: 1

Related Questions