![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 = |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Try:
Code:
grep "Database alias = DBIHP"$ z.dat |
|
#3
|
|||
|
|||
|
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 = |
|||
| Google The UNIX and Linux Forums |