Register a domain and help support LQ
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-10-2010, 08:35 PM   #1
jimmy the saint
LQ Newbie
Registered: Jul 2010
Posts: 1

Rep: Reputation: 0
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

Old 07-11-2010, 04:59 AM   #2
Registered: Mar 2006
Location: Czech Republic
Distribution: Gentoo, Chakra
Posts: 884
Blog Entries: 11

Rep: Reputation: 105Reputation: 105
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.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Kate: Append files to existing list and enable the Recent List AGazzaz Linux - Software 2 10-13-2009 09:27 PM
Downloading a list of files from a remote server using a list ralcocer Programming 2 02-11-2009 02:02 PM
How to list all files recursively, in a non-broken list? nyle Linux - Newbie 1 12-16-2008 11:52 PM
Script to list files in a given directory Azzath Programming 8 04-03-2008 08:02 AM
script to search inside list of files adam_blackice Programming 5 03-25-2008 10:35 AM

All times are GMT -5. The time now is 06:06 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration