The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search a list of lines in file into files sriram003 UNIX for Advanced & Expert Users 2 05-20-2008 08:23 AM
search for lines in a file shalua Shell Programming and Scripting 9 04-23-2008 12:28 AM
Can I search columns and print lines? Ant1815 UNIX for Dummies Questions & Answers 2 04-26-2007 08:01 AM
How can you show lines surrounding a search string? robster UNIX for Dummies Questions & Answers 3 06-07-2005 12:33 PM
Looking for a good way to search & destroy lines darthur UNIX for Dummies Questions & Answers 5 07-30-2002 01:14 PM

Closed Thread
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
  #1 (permalink)  
Old 12-13-2007
wereyou wereyou is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 19
View all lines in grep search

I am trying to grep a file and I need to show the schedules that the grep belongs too.

here is the command I am using and the result I am getting:

$ fgrep -e 'SCALHOL' twsschedules
EXCEPT SCALHOL -1 DAYS
EXCEPT SCALHOL -1 DAYS
EXCEPT SCALHOL -1 DAYS
EXCEPT SCALHOL -1 DAYS
EXCEPT SCALHOL -1 DAYS
EXCEPT SCALHOL -1 DAYS

What I need is to see the related schedules that the SCALHOL reside:

CPU id. Schedule Creator Last Updated
---------------- ---------------- -------------------------- ------------
HCSCPRODMLM SC_ML_TAP_DLY twsmast 11/17/07
SCHEDULE HCSCPRODMLM#SC_ML_TAP_DLY
ON EVERYDAY

EXCEPT SCALHOL -1 DAYS

CARRYFORWARD
PRIORITY 10
:
HCSCPRODOCM#SC_OC_RPB_1588
  #2 (permalink)  
Old 12-13-2007
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Post

Untested

Code:
#!/bin/perl -w
$block="";
$toprint=0;
while (<>) {
  if (/^CPU id. Schedule Creator Last Updated$/) {
    if ($toprint) { print $inblock }
    $block="";
    $toprint=0;
  }
  $block.=$_;
  if (/SCALHOL/) { $toprint=1 }
}


Last edited by Smiling Dragon; 12-13-2007 at 06:46 PM..
Closed Thread

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 06:52 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