The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Shell script to read lines in a text file and filter user data srimal Shell Programming and Scripting 4 4 Weeks Ago 01:35 AM
URGENT: Script/Function needed to read text property files in block wise ysreenivas Shell Programming and Scripting 7 05-11-2009 03:08 AM
help needed in a shell script for printing files shahshilpa Shell Programming and Scripting 1 01-06-2009 09:44 AM
shell script to read data from text file and to load it into a table in TOAD pallavishetty Shell Programming and Scripting 1 10-31-2008 04:15 AM
read list of filenames from text file and remove these files in multiple directories fxvisions Shell Programming and Scripting 5 08-07-2008 03:59 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 1 Week Ago
kashriram kashriram is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 5
Shell Script Needed to Read a text from a list files

Hi,

Below is my issue which I desperately need and I want a shell script which can do this job.

I need this script as I m planning to put this for a system health check. Please assist me.

1. There are 10 log files in a particular location.

2. open each log file. Goto to the end of the file. From the end go up to find a particular text. From this particular text till the end of the log search for another particular text.

3. if the particular text exists in the file return the file name(s) as the output.

Please help me with the script. Thanks a lot to all.

Thanks and Regards
Shriram
  #2 (permalink)  
Old 1 Week Ago
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,033
I think you're question is worded strangly, but based on what I think you want:

Code:
awk '
  /find1/ { P = 1 }
  P && /find2/ { print FILENAME; P = 0; nextfile}
' file*
Replace file* with your list of filenames, and find1 and find2 based on what you're looking for.
  #3 (permalink)  
Old 1 Week Ago
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,710
I agree the request is hard to understand but I think what is needed:
Code:
awk '/pattern 1/ {line1=FNR} 
                   /pattern 2/ {line2=FNR} 
                   END { if(line1 < line2) 
                             {print FILENAME}
                           }'  *.logfile > reportfile
where pattern1 is the first text pattern to find and pattern2 is the second pattern.
  #4 (permalink)  
Old 1 Week Ago
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,033
Oh, I see what you mean.
  #5 (permalink)  
Old 1 Week Ago
kashriram kashriram is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 5
Thanks a lot for your help, support and time. I will try this command and will get back shortly. Once again Thanks a LOT.
Sponsored Links
Reply

Bookmarks

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:27 AM.


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