I have almost 400 .sql files where i need to search for a specific pattern and output the results.
e.g
*file1.sql
select * from mydb.ops1_tbl from something1 <other n lines>
*file2.sql
select * from mydb.ops2_tbl from something2 <other n lines>
*file3.sql
select * from mydb.ops3_tbl ,mydb.ops4_tbl where a = b <other n lines>
expected result
file1.sql mydb.ops1_tbl
file2.sql mydb.ops2_tbl
file3.sql mydb.ops3_tbl mydb.ops4_tbl
Below script in powershell - able to fetch the filname
Get-ChildItem-Recurse-Filter*.sql|Select-String-pattern "mydb."|group path|select name
Below script in powershell - able to fetch the line
Get-ChildItem-Recurse-Filter*.sql |Select-String-pattern "mydb."|select line
I need in the above format, someone has any pointer?
Rakesh Jayaram http://blogs.msdn.com/b/rakesh_ramblings/