Thanks for the replies, but I don't think I covered the search fully.
The data I am searching for can be anywhere on the line, and the line
can be very large so I can't cut it. I am searching for data, but I
don't know what the data is. I know what it starts with and what it ends
with. example     @(#) data >     so I need to be able to cut upto the
@(#) and then after the first  > . This could also appear a few times in
the same file but with different data. I have tried grepping and putting
'.......' in place but the data is variable in size, so I can get a lot
of rubbish after the >. I will start to look into sed.

Thanks all,

Tony.

-----Original Message-----
From: Miark [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 19, 2003 4:47 PM
To: [EMAIL PROTECTED]
Subject: Re: [newbie] Help with a script


In Perl I would use a regular expression to match the text, then 
end up with the string you're looking for in $1. So, for instance

#!/usr/bin/perl

open FILE, "< filename";
while (<FILE>) {
  m/exp_here/;
  print "I found '$1'\n";
}
close FILE;


Miark


On Tue, 19 Aug 2003 16:05:31 +0100, "Tony S. Sykes"
<[EMAIL PROTECTED]> wrote:

> All,
> 
> I am struggling writing a script which greps a binary file (grep -a)
> which will remove all of the data before the characters I am looking
for
> and then to remove the data after another character so I have only the
> relevant info. When you grep the binary file the line is very long. I
am
> looking for only about 15 - 20 characters off the line. The problem is
> that it can be anywhere on the line so I can't use a simple cut. Would
> "ed" be able to do this? I am not looking for you to write the script,
> just pointers as to what commands I could use. So far I have got the
> grep done "grep -a '@(#)' <file>" but it's what I do to the line after
> that.
> 
> Thanks in advance,
> 
> Tony.
  

-+-+-+-+-+-+-+- Business Computer Projects - Disclaimer -+-+-+-+-+-+-+-

This message, and any associated attachment is confidential. If you have
received it in error, please delete it from your system, do not use or
disclose the information in any way, and notify either Tony S. Sykes
or the postmaster <mailto:[EMAIL PROTECTED]>  immediately.

The contents of this message may contain personal views which are not
necessarily the views of Business Computer Projects Ltd., unless
specifically stated.  

Whilst every effort has been made to ensure that emails and their
attachments are virus free, it is the responsibility of the recipient(s)
to verify the integrity of such emails.

 
Business Computer Projects Ltd
BCP House
151 Charles Street
Stockport
Cheshire
SK1 3JY
 
Tel: +44 (0)161 355-3000
Fax: +44 (0)161 355-3001
Web: http://www.bcpsoftware.com <http://www.bcpsoftware.com/> 

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to