Sponsored Content
Top Forums Shell Programming and Scripting How to refine results of grep -p Post 302077873 by priceb on Tuesday 27th of June 2006 09:33:41 AM
Old 06-27-2006
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 =
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Filter results through pipe with grep

ls -ltr | grep string How can I use regular expressions to filter the results provided even more. I am using the above command as a reference. (1 Reply)
Discussion started by: ckandreou
1 Replies

2. UNIX for Dummies Questions & Answers

List grep results

Hi I need to search for matching strings in a database and I want to print out all files that matches in "detail", which means that I want the output to contain datum of last saving. I only get the grep function tp print the actual file names which is not enough since the database is to large... (14 Replies)
Discussion started by: slire
14 Replies

3. UNIX for Dummies Questions & Answers

My ps -ef|grep command results are chopped off

On our one HP-UX 11i box, we have some very long paths defined. When I want to check on our user processes running, the resulting paths are chopped off. /xyz/abc/123/......./server/b is really a process running in the ..../server/bin directory. Is this a terminal problem or buffer length... (1 Reply)
Discussion started by: bsp18974
1 Replies

4. Shell Programming and Scripting

Refine awk

Hi The commnad shows the following o/p df -kh /abc/bds/ |awk {'print$5'} capacity 87% I want the o/p as 87 only Can we achieve this using a oneliner of sorts NB : Code tags not working with my google chrome , So wasn't able to place code in tags . Pls dont penalise :-) Thanks (6 Replies)
Discussion started by: ultimatix
6 Replies

5. UNIX for Dummies Questions & Answers

Acting on results from a grep command

Hi, I am currently reading a tar file and searching for a particular word using grep e.g. Plane. At the moment, if a sentence is found with the word "Plane" the sentence itself is piped to another file. Here is the code i am using; for jar in 'cat jar_file.tar'; do tar -tvf... (3 Replies)
Discussion started by: crunchie
3 Replies

6. Shell Programming and Scripting

Grep no results

Hello guys, I have been looking around but can't find the answer to my problem: If the grep command displays no results, print "no results have been found" and increment x. But if the grep command find something, do nothing. if echo "no results have been found $x" x=`expr $x + 1 `... (3 Replies)
Discussion started by: Benou
3 Replies

7. UNIX for Dummies Questions & Answers

How to do ls -l on results of grep and find?

Hi, Am running the command below to search for files that contains a certain string. grep -il "shutdown" `find . -type f -mtime -1 -print` | grep "^./scripts/active" How do I get it to do a ls -l on the list of files? I tried doing ls -l `grep -il "shutdown" `find . -type f -mtime -1... (5 Replies)
Discussion started by: newbie_01
5 Replies

8. Shell Programming and Scripting

How to analyse results of grep

Hi all, I'm working with a peice of software that runs on Linux that allows planning trips in cars through maps. This software has different variations depending on the type of car, e.g. BMW, Audi, Hyundai, etc... Each variation has a dependency on common external components that are not... (1 Reply)
Discussion started by: emoshaya
1 Replies

9. Shell Programming and Scripting

How to concatenate grep results?

hi, let's say we have input in files test1.txt, test2.txt, text3.txt ... ... ... ('...' means more files & lines not just 'dots') test1.txt has: A B C D ... ... ... test2.txt has A B C D ... ... ... (4 Replies)
Discussion started by: msonoth
4 Replies

10. Shell Programming and Scripting

Cannot get results from grep command

Hi, i have a file hello.log which as several line that look like the below 2015-12-07 09:46:56 0:339 120.111.12.12 POST /helloWorld 2015-12-07 09:46:57 0:439 122.111.12.12 POST /helloWorld .... when i grep expecting to see results like the below. ... (6 Replies)
Discussion started by: mohtashims
6 Replies
Test::Database::Driver(3pm)				User Contributed Perl Documentation			       Test::Database::Driver(3pm)

NAME
Test::Database::Driver - Base class for Test::Database drivers SYNOPSIS
package Test::Database::Driver::MyDatabase; use strict; use warnings; use Test::Database::Driver; our @ISA = qw( Test::Database::Driver ); sub _version { my ($class) = @_; ...; return $version; } sub create_database { my ( $self ) = @_; ...; return $handle; } sub drop_database { my ( $self, $name ) = @_; ...; } sub databases { my ($self) = @_; ...; return @databases; } DESCRIPTION
"Test::Database::Driver" is a base class for creating "Test::Database" drivers. METHODS
The class provides the following methods: new( %args ) Create a new "Test::Database::Driver" object. If called as "Test::Database::Driver->new()", requires a "driver" parameter to define the actual object class. make_handle() Create a new "Test::Database::Handle" object, attached to an existing database or to a newly created one. The decision whether to create a new database or not is made by "Test::Database::Driver" based on the information in the mapper. See "TEMPORARY STORAGE ORGANIZATION" for details. make_dsn( %args ) Return a Data Source Name based on the driver's DSN, with the key/value pairs contained in %args as additional parameters. This is typically used by "dsn()" to make a DSN for a specific database, based on the driver's DSN. name() dbd() The driver's short name (everything after "Test::Database::Driver::"). base_dir() The directory where the driver should store all the files for its databases, if needed. Typically used by file-based database drivers. version() "version" object representing the version of the underlying database enginge. This object is build with the return value of "_version()". version_string() Version string representing the version of the underlying database enginge. This string is the actual return value of "_version()". dbd_version() The version of the DBD used to connect to the database engine, as returned by "VERSION()". driver_dsn() Return a driver Data Source Name, sufficient to connect to the database engine without specifying an actual database. username() Return the connection username. password() Return the connection password. connection_info() Return the connection information triplet ("driver_dsn", "username", "password"). version_matches( $request ) Return a boolean indicating if the driver's version matches the version constraints in the given request (see Test::Database documentation's section about requests). The class also provides a few helpful commands that may be useful for driver authors: available_dbname() Return an unused database name that can be used to create a new database for the driver. dsn( $dbname ) Build a Data Source Name for the database with the given $dbname, based on the driver's DSN. WRITING A DRIVER FOR YOUR DATABASE OF CHOICE
The SYNOPSIS contains a good template for writing a "Test::Database::Driver" class. Creating a driver requires writing the following methods: _version() Return the version of the underlying database engine. create_database( $name ) Create the database for the corresponding DBD driver. Return a "Test::Database::Handle" in case of success, and nothing in case of failure to create the database. drop_database( $name ) Drop the database named $name. Some methods have defaults implementations in "Test::Database::Driver", but those can be overridden in the derived class: is_filebased() Return a boolean value indicating if the database engine is file-based or not, i.e. if all the database information is stored in a file or a directory, and no external database server is needed. databases() Return the names of all existing databases for this driver as a list (the default implementation is only valid for file-based drivers). TEMPORARY STORAGE ORGANIZATION
Subclasses of "Test::Database::Driver" store useful information in the system's temporary directory, under a directory named Test-Database-$user ($user being the current user's name). That directory contains the following files: database files The database files and directories created by file-based drivers controlled by "Test::Database" are stored here, under names matching tdd_DRIVER_N, where DRIVER is the lowercased name of the driver and N is a number. the mapping.yml file A YAML file containing a "cwd()" / database name mapping, to enable a given test suite to receive the same database handles in all the test scripts that call the "Test::Database-"handles()> method. AUTHOR
Philippe Bruhat (BooK), "<book@cpan.org>" COPYRIGHT
Copyright 2008-2010 Philippe Bruhat (BooK), all rights reserved. LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-11-27 Test::Database::Driver(3pm)
All times are GMT -4. The time now is 05:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy