?
Solved

Searching part of a file

Posted on 1997-05-23
1
Medium Priority
?
175 Views
Last Modified: 2013-12-25
I was wondering if anyone knows where i could
find a script, or knows the procedure that would allow
me to search parts of *one* file for string. I.e. We have a list of names with an email address and would like to be able to have an engine search inside the file for the names instead of searching for a file with the names.. Thanks in advance :)
0
Comment
Question by:Primetyme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
icd earned 300 total points
ID: 1828086
Assuming your file is of the form

email@somewhere.com,fred bloggs

then you can search it with a perl script similar to:-

open (FID, "filename.txt");
while (<FID>) {
  chop;
  ($email, $name) = split(/,/, $_);
  if ($name eq $theNameIAmLookingFor) {
    print "The email you want is $email\n";
  }
}
close(FID);

Alternatively if it is a Unix host you could use a grep program.

0

Featured Post

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to dynamically set the form action using jQuery.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question