Issue
How can I get the complete file path when I use grep
?
I use commands like
cat *.log | grep somethingtosearch
I need to show the result with the complete file path from where the matched result were taken out.
How can I do it?
Solution
Assuming you have two log-files in:
- C:/temp/my.log
- C:/temp/alsoMy.log
'cd' to C: and use:
grep -r somethingtosearch temp/*.log
It will give you a list like:
temp/my.log:somethingtosearch
temp/alsoMy.log:somethingtosearch1
temp/alsoMy.log:somethingtosearch2
Answered By - Kaadzia Answer Checked By - Senaida (WPSolving Volunteer)