The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Extracting a string from one file and searching the same string in other files mohancrr Shell Programming and Scripting 1 09-19-2007 04:17 AM
Perl: searching for a string in a file... pondlife Shell Programming and Scripting 4 09-17-2007 08:35 AM
Hi! Searching for a text string in UNIX skwadim UNIX for Dummies Questions & Answers 1 12-22-2006 01:13 PM
Searching directory for file that contains some text. LordJezo UNIX for Dummies Questions & Answers 4 04-04-2006 09:58 PM
Help with searching a text file thekid2 Shell Programming and Scripting 6 01-02-2004 02:09 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-28-2008
meevagh meevagh is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 7
PERL: Searching for a string in a text file problem

Looking for a bit of help. I need to search for a string of words, but unfortunately these words are located on separate lines.

for example the text output is:

United
Chanmpions
Ronaldo
Liverpool
Losers
Torres


and my script code is

print("DEBUG - checking file message");
while (<FILE>){
$line = $_;

if($line =~ /United/ ){
print("\nAbout to send email\n");
sendEmail($contacts,
"",
"Monitoring",
"\nPlease be aware that there is a problem.",
"",
"");
}

the above script will send out an e-mail when it locates United, but I need to send out an e-mail when it gets United Champions Ronaldo.

I thought something like
if($line =~ /United/n Champions/n Ronaldo/)

But no luck.

Any suggestions as to how to go about this.
 

Bookmarks

Tags
linux, perl, perl shift, shift, shift perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0