Brian Smith
asked on
How can I force the file content search to include all subdirectories?
Hi Expert,
I manage to lookup and display the full line of content of all txt file (based on the criteria below).
However, I would like:
1) the searches to include all subdirectories (not just from the root)
2) output both the the respective subfoldername * filename of detected file which contents the target keyword (other than just the text line)
My current ps1 script:-
$Content = Get-Content E:\*.txt
$Content | Foreach {
if ($_ -like "CurrentEdition=*,*") {Write-Output $_}
}
Please help.
I manage to lookup and display the full line of content of all txt file (based on the criteria below).
However, I would like:
1) the searches to include all subdirectories (not just from the root)
2) output both the the respective subfoldername * filename of detected file which contents the target keyword (other than just the text line)
My current ps1 script:-
$Content = Get-Content E:\*.txt
$Content | Foreach {
if ($_ -like "CurrentEdition=*,*") {Write-Output $_}
}
Please help.
ASKER
Hi oBdA,
Thank you for your suggestion.
Your ps1 commandline given did list down all the *.txt filename + the respective directory (including sub-directories).
So now, how can I combined both of my script and your's together, so that the end result will show me both (the entire line of file content that met the search criteria together with the respective filename + the path location) info simultaneously?
Thank you for your suggestion.
Your ps1 commandline given did list down all the *.txt filename + the respective directory (including sub-directories).
So now, how can I combined both of my script and your's together, so that the end result will show me both (the entire line of file content that met the search criteria together with the respective filename + the path location) info simultaneously?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect! Thank you so much for making my day :)
Open in new window