>>>>> "Phil" == Phil Scarratt <[email protected]> writes:

Phil> Kyle wrote:
>> Hi Folks,
>> 
>> I am trying to extract a substring from a string found in a file.
>> 
>> The string is: *** End of TF0220 at Thu Jul 2 10:06:51 EST 2009 -
>> RC = 0
>> 
>> and the substring I want to extract is TF0220. This is a program
>> name and the length of this name varies. In other words I want to
>> extract whatever is between the words "of" and "at" in a script.
>> 
>> How would I likely go about that please?
>> 

Phil> Something like this would work:

Phil> cat <file> | perl -nle
Phil> 'if(/^\*\*\*\s+End\s+of\s+([\S]+)\s+at\s+.*/){print $1;}'


Why use cat?

Why not <file perl ...

The extra process plus pipe just wastes resources.

--
Dr Peter Chubb  http://www.gelato.unsw.edu.au  peterc AT gelato.unsw.edu.au
http://www.ertos.nicta.com.au           ERTOS within National ICT Australia
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to