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
My ps -ef|grep command results are chopped off bsp18974 UNIX for Dummies Questions & Answers 1 08-14-2007 11:35 AM
How to display first 7 char of grep results? kthatch UNIX for Dummies Questions & Answers 8 04-05-2007 02:00 AM
List grep results slire UNIX for Dummies Questions & Answers 14 10-31-2006 11:42 AM
Filter results through pipe with grep ckandreou UNIX for Dummies Questions & Answers 1 07-10-2006 03:04 PM
Multiple Grep Results - Formatting sysera Shell Programming and Scripting 7 03-25-2004 06:04 AM

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 06-27-2006
priceb priceb is offline
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 =
  #2 (permalink)  
Old 06-28-2006
thestevew thestevew is offline
Registered User
  
 

Join Date: Mar 2006
Location: South Yorkshire, UK
Posts: 114
Try:
Code:
grep "Database alias = DBIHP"$ z.dat
  #3 (permalink)  
Old 06-28-2006
priceb priceb is offline
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 =
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 11:38 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