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
search for a string spread in multiple line finder255 Shell Programming and Scripting 1 10-22-2008 04:25 PM
Multiple Line search using grep pistachio UNIX for Dummies Questions & Answers 6 09-06-2008 11:11 AM
Perl: Match a line with multiple search patterns Juha Shell Programming and Scripting 10 04-09-2008 01:43 AM
Multiple file processing - 1st line only to process - search/match substring toneatlondon Shell Programming and Scripting 2 01-02-2008 09:20 PM
two lines into one colon separated line... tonlu Shell Programming and Scripting 2 03-30-2005 10:27 AM

Closed Thread
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 12-21-2008
suryanarayana suryanarayana is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 15
multiple search separated by blank line

hi all

I want to get multiple search that are separated by blank line according to first search in text file

eg: egrep 'x|Y|Z' file


in that for each x...it should be seperated by blank line


will u pls help
  #2 (permalink)  
Old 12-22-2008
reddyrajal reddyrajal is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 24
grep -B 1 ^$ | egrep 'x|Y|Z' file

^$ for blank line and -B 1 prints blank line and before line
  #3 (permalink)  
Old 12-22-2008
suryanarayana suryanarayana is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 15
multiple search separated by blank line

I am not getting pls help


Quote:
Originally Posted by suryanarayana View Post
hi all

I want to get multiple search that are separated by blank line according to first search in text file

eg: egrep 'x|Y|Z' file


in that for each x...it should be seperated by blank line


will u pls help
  #4 (permalink)  
Old 12-22-2008
reddyrajal reddyrajal is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 24
sorry command is

grep -B 1 ^$ file | egrep 'x|Y|Z'

can u post sample data
  #5 (permalink)  
Old 12-22-2008
suryanarayana suryanarayana is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 15
multiple search separated by blank line

Pls examine this...
grep -B 1 ^$ | egrep 'Enter|@|SQL RUN' dat

Enter value for authid: 560000
SQL RUN TIME--- 22-12-2008 13:57:29
@lienup.sql SELECTED VALUE
Enter value for authid: 560000
SQL RUN TIME--- 22-12-2008 13:57:29
@lienup.sql SELECTED VALUE
...........................................


before.....every first one (ie Enter valur for authid ..)
i should get blank line

thx in advance


Quote:
Originally Posted by reddyrajal View Post
sorry command is

grep -B 1 ^$ file | egrep 'x|Y|Z'

can u post sample data
  #6 (permalink)  
Old 12-22-2008
reddyrajal reddyrajal is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 24
cat list
DELETE:MD:TM,432350214576013;

RESP:940120105;
DELETE:MD:TM,432350415547447;

RESP:940120105;

SET:NOK:TM,432350110811018:T22,0;

RESP:11000999;
SET:MD:TM,4323500223734641;

RESP:0;
SET:NOK:TM,432350220813251:BAIC,1;
RESP:0;



SET:MD:TM,4323502142003351;

RESP:0;
DELETE:MD:TM,432350415283715;

RESP:0;
DELETE:MD:TM,432350415434001;

RESP:0;
SET:MD:TRIM,989370025055:LANG,English;
RESP:0;



DELETE:MD:TM,432350041977269:TRIM,989371036084;;

RESP:940120105;
SET:MD:TM,432350214483040;

RESP:0;
DELETE:MD:TM,432350021443483:TRIM,989362585071;

RESP:0;


grep -B 1 ^$ list | egrep 'DELETE|SET'
DELETE:MD:TM,432350214576013;
DELETE:MD:TM,432350415547447;
SET:NOK:TM,432350110811018:T22,0;
SET:MD:TM,4323500223734641;
SET:MD:TM,4323502142003351;
DELETE:MD:TM,432350415283715;
DELETE:MD:TM,432350415434001;
DELETE:MD:TM,432350041977269:TRIM,989371036084;;
SET:MD:TM,432350214483040;
DELETE:MD:TM,432350021443483:TRIM,989362585071;
  #7 (permalink)  
Old 12-22-2008
reddyrajal reddyrajal is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 24
cat file

Enter value for authid: 560000
SQL RUN TIME--- 22-12-2008 13:57:29
@lienup.sql SELECTED VALUE
Enter value for authid: 560000
SQL RUN TIME--- 22-12-2008 13:57:29
@lienup.sql SELECTED VALUE

Enter value for authid: 560001
SQL RUN TIME--- 22-12-2008 13:57:30
@lienup.sql SELECTED VALUE
Enter value for authid: 560001
SQL RUN TIME--- 22-12-2008 13:57:30
@lienup.sql SELECTED VALUE


Enter value for authid: 560002
SQL RUN TIME--- 22-12-2008 13:57:40
@lienup.sql SELECTED VALUE
Enter value for authid: 560002
SQL RUN TIME--- 22-12-2008 13:57:40
@lienup.sql SELECTED VALUE


Enter value for authid: 560003
SQL RUN TIME--- 22-12-2008 13:57:50
@lienup.sql SELECTED VALUE
Enter value for authid: 560003
SQL RUN TIME--- 22-12-2008 13:57:50
@lienup.sql SELECTED VALUE



grep -A 3 ^$ file | egrep 'Enter|SQL RUN|@'
Enter value for authid: 560000
SQL RUN TIME--- 22-12-2008 13:57:29
@lienup.sql SELECTED VALUE
Enter value for authid: 560001
SQL RUN TIME--- 22-12-2008 13:57:30
@lienup.sql SELECTED VALUE
Enter value for authid: 560002
SQL RUN TIME--- 22-12-2008 13:57:40
@lienup.sql SELECTED VALUE
Enter value for authid: 560003
SQL RUN TIME--- 22-12-2008 13:57:50
@lienup.sql SELECTED VALUE


or try this grep -A 10 ^$ file | egrep -m 3 'Enter|SQL RUN|@'

Last edited by reddyrajal; 12-23-2008 at 02:58 AM..
Closed Thread

Bookmarks

Tags
awk, awk trim, trim, trim awk

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 10: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