title: Greping a text file on local machine where search string is variable and user fed
body: <p>This will be just a noobie question: This is one step of a multistage process which runs predominantly in IMACROS. So I need a solution which I can access by IMACROS in firefox browser. I have a working solution, but I know there is a faster, better and elegant solution and something which I can run locally on my computer.</p>
  
  <p><strong>I cannot do CTRL+F and search since it will be automated and IMACROS do not support keyboard shortcuts.</strong></p>
  
  <p>I have a imacros script which extracts a text string from a website, feeds it as input to a (my 1000 line text file is preloaded in the text area) online grep utility at: <a href="http://www.online-utility.org/text/grep.jsp" rel="nofollow">http://www.online-utility.org/text/grep.jsp</a>  and then extracts the first matching line and parses the output in required format using javascript and then submits this extracted and parsed text string to another website.</p>
  
  <p><strong>ATTEMPTS &amp; LIMITATIONS:</strong></p>
  
  <ol>
  <li><p>I tried using imacros SEARCH command, but it takes hardcoded search
  string. I need something where it can take the search string as
  variable, since the search string changes at every iteration.</p></li>
  <li><p>I can programs whole thing in javascript and then do all the
  processing at each iteration .i.e. read the file, search and then
  output), But that will be unnecessary repeated reading the file from local
  hard disk and will be CPU intensive. THIS STEP IS DONE 100K+ times a
  day. (THIS WILL BE SLOW AND VERY MUCH CPU INTENSIVE, I AM RUNNING THESE
  SCRIPTS IN VIRTUALBOX, SO RESOURCES ARE TIGHT)</p></li>
  <li><p>I can program imacros to output search string to a file and then
  write a shell script to run every 0.1 seconds and get content of
  this newly created file and use (grep, sed or awk) to search and output in another
  file and from where IMACROS can read the string and feed it to
  another website. (THIS WILL HAVE ISSUES SINCE SCRIPT WILL BE RUNNING NON-STOP AND I 
  NEED IT TO BE 100% ACCURATE, ANY ERROR AND IT STOPS THE WHOLE PROCESS DOWNSTREAM AND 
  I HAVE TO CORRECT IT MANUALLY AT THE END OF THE DAY, PLAUSIBLE SOLUTION WILL BE 
  SOMETHING WHERE SCRIPT IS CALLED ONLY WHEN REQUIRED, I WILL BE MULTI-THREADING IT)</p></li>
  </ol>
  
  <p>I need to be able to do it locally on my browser. Something like a search page, with input box for variable string and button to click and then it uses my CPU to search for the string in the HTML which can have the 1000 lines of text embedded in it (so basically it can search the HTML) or it can search the link to the local TXT file and show the output on same page.</p>
  
  <p>A local clone of <a href="http://www.online-utility.org/text/grep.jsp" rel="nofollow">http://www.online-utility.org/text/grep.jsp</a> will be perfect solution. But without all the ads and extra menus and stuff. Something which can cut short 2-3 seconds of the search and response time the online utility now takes.</p>
  
  <p>Each second saved amounts to a lot of time savings. Simplest, creative and elegant solution is what I am looking for.</p>