Need advice on a script to search many files for list of terms, append hits to list
Let me start by saying this will be my first bash script (if I can pull it off) so please by kind.
I have a list of terms I need to search a set of 8 files for. I will settled on grep (rgrep) for the searching. I need an indication of what file the term was found in appended to that terms line in the list file.
For example, if TERM shows up in HTML1 and HTML2, I would like the line to look like "TERM - HTML1 HTML2"
Beyond the fact that I will use rgrep, I have no idea where to go from here. Can anyone point me in the right direction? What kinds of things should I be looking at? Would cat or sed be best for this? Is there a site with good template scripts I can look at and perhaps modify for this purpose?
Sorry if these questions are a bit noobish, but I am, after all, a complete noob!
Thanks in advance for any advice
Hi, a great place to read about scripting is Grymoire
grep -o "regex" "filename" will output "filename":"regex" if there is a match. after that you pipe it to sort -u to avoid duplicate filematches. to finish, some awk magic might just do the trick to get you the output format you want.
If have time, I'll post more detailed suggestions.
|All times are GMT -5. The time now is 03:21 PM.|