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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
My ps -ef|grep command results are chopped off bsp18974 UNIX for Dummies Questions & Answers 1 08-14-2007 07:35 AM
How to display first 7 char of grep results? kthatch UNIX for Dummies Questions & Answers 8 04-04-2007 10:00 PM
List grep results slire UNIX for Dummies Questions & Answers 14 10-31-2006 08:42 AM
Filter results through pipe with grep ckandreou UNIX for Dummies Questions & Answers 1 07-10-2006 11:04 AM
Multiple Grep Results - Formatting sysera Shell Programming and Scripting 7 03-25-2004 03:04 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-27-2006
Registered User
 

Join Date: Jul 2005
Posts: 5
How to refine results of grep -p

I need help to further reduce the output shown below. I want to be able to only return the paragraph where the 'Database alias' is exactly equal to DBIHP. I do not want the other paragraphs being shown below.


[diimps1@aixudbtest1 /home/dbadvlp]$ echo $dbalias
DBIHP


[diimps1@aixudbtest1 /home/dbadvlp]$ db2 list db directory|grep -p 'Database alias = '$dbalias
Database alias = DBIHPP1
Database name = DBIHPP1
Local database directory = /db2udb/diimps1/dbihpp1/dbpath
Database release level = a.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =

Database alias = DBIHPS1
Database name = DBIHPS1
Local database directory = /db2udb/diimps1/dbihps1/dbpath
Database release level = a.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =

Database alias = DBIHP
Database name = DBIHP
Local database directory = /db2udb/diimps1/dbihp/dbpath
Database release level = a.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =

Database alias = DBIHPC1
Database name = DBIHPC1
Local database directory = /db2udb/diimps1/dbihpc1/dbpath
Database release level = a.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Reply With Quote
Forum Sponsor
  #2  
Old 06-28-2006
Registered User
 

Join Date: Mar 2006
Location: South Yorkshire, UK
Posts: 114
Try:
Code:
grep "Database alias = DBIHP"$ z.dat
Reply With Quote
  #3  
Old 06-28-2006
Registered User
 

Join Date: Jul 2005
Posts: 5
Thanks, this works!!

thestevew,
Thanks, I was able to get this to work (see my final code below). My question is, what does the $ sign on the end of the string mean?? Does it mean end of line??

[diimps1@aixudbtest1 /db2udb/diimps1]$ export dbalias=DBIHP

[diimps1@aixudbtest1 /db2udb/diimps1]$ db2 list db directory|grep -p "Database alias = "$dbalias$
Database alias = DBIHP
Database name = DBIHP
Local database directory = /db2udb/diimps1/dbihp/dbpath
Database release level = a.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0