Sponsored Content
Full Discussion: Cut Lines using grep
Top Forums Shell Programming and Scripting Cut Lines using grep Post 302684861 by bhupinder08 on Friday 10th of August 2012 07:38:43 AM
Old 08-10-2012
Thanks for your reply.

Will egrep cut the lines from file_a?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep and cut....

hi, i have a simple question: in hpux 11i; this cmd : cat mailtest |grep sekar >test1 gives the output file with the name test1. i want to remove the line which contains the "sekar" and put the result in the new file.... what is the command for that?.. (2 Replies)
Discussion started by: sekar sundaram
2 Replies

2. Shell Programming and Scripting

cut sed grep or other?

Hi Is there a way to cut the last two characters off a word or number given that this word or number can be of varying length? I have tried something like TEST=`echo $OLD | cut -c 1-5` where $OLD is a variable containing a number like 1234567 which gives a result of 12345. This is fine... (4 Replies)
Discussion started by: rleebife
4 Replies

3. Shell Programming and Scripting

tail, grep and cut

Hello all, I have some weird problem that kinda baffles me. Say I have the following test file: claudia:~/tmp$ cat testfile.txt This is a test line This is the second test line And yeah, this is the third test line Then say I want to tail the file, grep for the word "third" then... (7 Replies)
Discussion started by: sylaan
7 Replies

4. UNIX for Dummies Questions & Answers

grep and cut problem

Hello folks, I have to (e)grep out a certain pattern e.g. <TAG1> from a huge log file which does not have any space as such. The thing is that once I have 'grep'ed out the <TAG1> from the file I need to extract the content within the tags, i.e, <TAG1>Data_To_Be_Extracted</TAG1> The underlined... (9 Replies)
Discussion started by: Rajat
9 Replies

5. Shell Programming and Scripting

Using grep and cut within awk

Hi My input file looks like as follows: say a.txt "aaaa cc","224 AW","ss cccccc","P06 09/10","dddddd" "aaaa cc","224 AW","ss cccccc","P06 09/10","dddddd" "aaaa cc","224 AW","ss cccccc","P06 09/10","dddddd" "aaaa cc","224 AW","ss cccccc","P06 09/10","dddddd" "aaaa cc","224 AW","ss... (5 Replies)
Discussion started by: bittoo
5 Replies

6. Shell Programming and Scripting

AIX equivalent to GNU grep's -B and -A [print lines after or before matching lines]

Hi folks I am not allowed to install GNU grep on AIX. Here my code excerpt: grep_fatal () { /usr/sfw/bin/gegrep -B4 -A2 "FATAL|QUEUE|SIGHUP" } Howto the same on AIX based machine? from manual GNU grep ‘--after-context=num’ Print num lines of trailing context after... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

7. Slackware

How should I cut this line using cut and grep?

not sure how to do it. wan't to delete it using cut and grep ince i would use it in the shell. but how must the command be? grep "64.233.181.103 wwwGoogle.com" /etc/hosts | cut -d the delimeter is just a space. can you help meplease. :D (1 Reply)
Discussion started by: garfish
1 Replies

8. Shell Programming and Scripting

Perl XML, find matching condition and grep lines and put the lines somewhere else

Hi, my xml files looks something like this <Instance Name="New York"> <Description></Description> <Instance Name="A"> <Description></Description> <PropertyValue Key="false" Name="Building A" /> </Instance> <Instance Name="B"> ... (4 Replies)
Discussion started by: tententen
4 Replies

9. Shell Programming and Scripting

grep with cut option??

This is my command-line code in my script, passwd=`grep $passwd $userfile | cut -f2 -d: login_users > retrieve` the cut -f2 -d: login_users > retrieve searches and prints the whole column two. what I need is one of the items in the column two only.. what option can I add to my cut... (2 Replies)
Discussion started by: jenimesh19
2 Replies

10. UNIX for Dummies Questions & Answers

Cut particular lines

All, I would like to cut all the lines from the log file for the timestamp . I'm not clear about how to apply grep ,awk here.Can you help me on this ? My logfile: ********** Wed Feb 20 03:48:26 2013 Thread 1 advanced to log sequence 400 (LGWR switch) Thu Feb 21 02:34:23 2013... (1 Reply)
Discussion started by: arul1185
1 Replies
Alzabo::RDBMSRules(3pm) 				User Contributed Perl Documentation				   Alzabo::RDBMSRules(3pm)

sub reverse_engineer {
    my $self = shift;
    my $schema = shift;

	   my $dbh = $schema->driver->handle;

	   foreach my $table ( $dbh->tables )
	   {
	       my $t = $schema->make_table( name => $table );

	       $self->reverse_engineer_table($t);
	   }
       }

       sub reverse_engineer_table {
	   my $self = shift;
	   my $table = shift;

	   my $dbh = $table->schema->driver->handle;

	   my $sth = $dbh->column_info( undef, $table->schema->name, $table->name, undef );

	   while ( my $col_info = $sth->fetchrow_hashref )
	   {
	       use Data::Dumper; warn Dumper $col_info;
	       my %attr = ( name     => $col_info->{COLUMN_NAME},
			    type     => $col_info->{TYPE_NAME},
			    nullable => $col_info->{NULLABLE} ? 1 : 0,
			  );

	       $attr{size} =
		   $col_info->{COLUMN_SIZE} if $col_info->{COLUMN_SIZE};

	       $attr{precision} =
		   $col_info->{DECIMAL_DIGITS} if $col_info->{DECIMAL_DIGITS};

	       $attr{default} =
		   $col_info->{COLUMN_DEF} if defined $col_info->{COLUMN_DEF};

	       $attr{comment} =
		   $col_info->{REMARKS} if defined $col_info->{REMARKS};

	       $table->make_column(%attr);
	   }

	   $self->reverse_engineer_table_primary_key($table);
       }

       sub reverse_engineer_table_primary_key {
	   my $self = shift;
	   my $table = shift;

	   my $dbh = $table->schema->driver->handle;

	   my $sth = $dbh->column_info( undef, $table->schema->name, $table->name );

	   while ( my $pk_info = $sth->fetchrow_hashref )
	   {
	       $table->add_primary_key( $table->column( $pk_info->{COLUMN_NAME} ) );
	   }
       }

NAME
Alzabo::RDBMSRules - Base class for Alzabo RDBMS rulesets SYNOPSIS
use Alzabo::RDBMSRules; my $rules = Alzabo::RDBMSRules( rules => 'MySQL' ); DESCRIPTION
This class is the base class for all "Alzabo::RDBMSRules" modules. To instantiate a subclass call this class's "new()" method. See the "SUBCLASSING Alzabo::RDBMSRules" section for information on how to make a ruleset for the RDBMS of your choice. METHODS
available A list of names representing the available "Alzabo::RDBMSRules" subclasses. Any one of these names would be appropriate as the "rdbms" parameter for the "Alzabo::RDBMSRules->new()" method. new The constructor always accepts one parameter, "rdbms", which is the name of the RDBMS to be used. Some subclasses may accept additional values. The constructor returns a new "Alzabo::RDBMSRules" object of the appropriate subclass. Throws: "Alzabo::Exception::Eval" schema_sql ("Alzabo::Create::Schema" object) Returns a list of SQL statements which would create the given schema. index_sql ("Alzabo::Create::Index" object) Returns a list of SQL statements to create the specified index. drop_table_sql ("Alzabo::Create::Table" object) Returns a list of SQL statements to drop the specified table. drop_index_sql ("Alzabo::Create::Index" object) Returns a list of SQL statements to drop the specified index. schema_sql_diff This method takes two parameters: * new => "Alzabo::Create::Schema" object * old => "Alzabo::Create::Schema" object This method compares the two schema objects and returns an array of SQL statements which turn the "old" schema into the "new" one. table_sql_diff This method takes two parameters: * new => "Alzabo::Create::Table" object * old => "Alzabo::Create::Table" object This method compares the two table objects and returns an array of SQL statements which turn the "old" table into the "new" one. type_is_numeric ("Alzabo::Column" object) Returns a boolean indicating whether or not the column is numeric (integer or floating point). quote_identifiers Returns true or false to indicate whether or not the generated DDL SQL statements should have their identifiers quoted or not. This may be overridden by subclasses. It defaults to false. can_alter_table_name If this is true, then when syncing a schema, the object will call "alter_table_name_sql()" to change the table's name. Otherwise it will call "recreate_table_sql()". can_alter_column_name If this is true, then when syncing a schema, the object will call "alter_column_name_sql()" to change the table's name. Otherwise it will call "recreate_table_sql()". Virtual Methods The following methods are not implemented in the "Alzabo::RDBMSRules" class itself and must be implemented in its subclasses. column_types Returns a list of valid column types. feature ($feature) Given a string defining a feature, this method indicates whether or not the given RDBMS supports that feature. By default, this method always returns false unless overridden in the subclass. Features that may be asked for: * extended_column_types Column types that must be input directly from a user, as opposed to being chosen from a list. MySQL's ENUM and SET types are examples of such types. * index_column_prefixes MySQL supports the notion of column prefixes in indexes, allowing you to index only a portion of a large text column. * fulltext_indexes This should be self-explanatory. * functional_indexes Indexes on functions, as supported by PostgreSQL. validate_schema_name ("Alzabo::Schema" object) Throws an "Alzabo::Exception::RDBMSRules" if the schema's name is not valid. validate_table_name ("Alzabo::Create::Table" object) Throws an "Alzabo::Exception::RDBMSRules" if the table's name is not valid. validate_column_name ("Alzabo::Create::Column" object) Throws an "Alzabo::Exception::RDBMSRules" if the column's name is not valid. validate_column_type ($type_as_string) Throws an "Alzabo::Exception::RDBMSRules" if the type is not valid. This method returns a canonized version of the type. validate_column_length ("Alzabo::Create::Column" object) Throws an "Alzabo::Exception::RDBMSRules" if the length or precision is not valid for the given column. validate_column_attribute This method takes two parameters: * column => "Alzabo::Create::Column" object * attribute => $attribute This method is a bit different from the others in that it takes an existing column object and a potential attribute. It throws an "Alzabo::Exception::RDBMSRules" if the attribute is is not valid for the column. validate_primary_key ("Alzabo::Create::Column" object) Throws an "Alzabo::Exception::RDBMSRules" if the column is not a valid primary key for its table. validate_sequenced_attribute ("Alzabo::Create::Column" object) Throws an "Alzabo::Exception::RDBMSRules" if the column cannot be sequenced. validate_index ("Alzabo::Create::Index" object) Throws an "Alzabo::Exception::RDBMSRules" if the index is not valid. table_sql ("Alzabo::Create::Table" object) Returns an array of SQL statements to create the specified table. column_sql ("Alzabo::Create::Column" object) Returns an array of SQL statements to create the specified column. foreign_key_sql ("Alzabo::Create::ForeignKey" object) Returns an array of SQL statements to create the specified foreign key. drop_column_sql ("Alzabo::Create::Column" object) Returns an array of SQL statements to drop the specified column. drop_foreign_key_sql ("Alzabo::Create::ForeignKey" object) Returns an array of SQL statements to drop the specified foreign key. column_sql_add ("Alzabo::Create::Column" object) Returns an array of SQL statements to add the specified column. column_sql_diff This method takes two parameters: * new => "Alzabo::Create::Column" object * old => "Alzabo::Create::Column" object This method compares the two table objects and returns an array of SQL statements which turn the "old" table into the "new" one. index_sql_diff This method takes two parameters: * new => "Alzabo::Create::Index" object * old => "Alzabo::Create::Index" object This method compares the two index objects and returns an array of SQL statements which turn the "old" index into the "new" one. alter_primary_key_sql This method takes two parameters: * new => "Alzabo::Create::Table" object * old => "Alzabo::Create::Table" object This method compares the two table objects and returns an array of SQL statements which alter the "old" one's primary key to match the "new" one's. alter_table_name_sql ("Alzabo::Create::Table" object) Given a table, this method is expected to change the table's name from "$table->former_name" to "$table->name". This will only be called if the rules object returns true for "can_alter_table_name()". alter_column_name_sql ("Alzabo::Create::Table" object) Given a column, this method is expected to change the table's name from "$column->former_name" to "$column->name". This will only be called if the rules object returns true for "can_alter_column_name()". recreate_table_sql This method takes two parameters: * new => "Alzabo::Create::Table" object * old => "Alzabo::Create::Table" object This method is expected to drop the old table and create the new one. However, it must preserve all the data stored in the old table, excluding data in columns that are being dropped. Additionally, if there are sequences associated with columns in the old table, they should not be dropped. This method will only be called if either "can_alter_table_name()" or "can_alter_column_name()" return false. reverse_engineer ("Alzabo::Create::Schema" object) Given a schema object (which presumably has no tables), this method uses the schema's "Alzabo::Driver" object to connect to an existing database and reverse engineer it into the appropriate Alzabo objects. type_is_integer ("Alzabo::Column" object) Returns a boolean indicating whether or not the column is an integer type. type_is_floating_point ("Alzabo::Column" object) Returns a boolean indicating whether or not the column is a floating point type. type_is_character ("Alzabo::Column" object) Returns a boolean indicating whether or not the column is a character type. This is defined as any type which is defined to store text, regardless of length. type_is_date ("Alzabo::Column" object) Returns a boolean indicating whether or not the column is a date type. This is not true for datetime types. type_is_datetime ("Alzabo::Column" object) Returns a boolean indicating whether or not the column is a datetime type. This is not true for date types. type_is_time ("Alzabo::Column" object) Returns a boolean indicating whether or not the column is a time type. This is not true for datetime types. type_is_time_interval ("Alzabo::Column" object) Returns a boolean indicating whether or not the column is a time interval type. SUBCLASSING Alzabo::RDBMSRules To create a subclass of "Alzabo::RDBMSRules" for your particular RDBMS is fairly simple. Here's a sample header to the module using a fictional RDBMS called FooDB: package Alzabo::RDBMSRules::FooDB; use strict; use vars qw($VERSION); use Alzabo::RDBMSRules; use base qw(Alzabo::RDBMSRules); The next step is to implement a "new()" method and the methods listed under the section "Virtual Methods". The new method should look a bit like this: 1: sub new 2: { 3: my $proto = shift; 4: my $class = ref $proto || $proto; 5: my %p = @_; 6: 7: my $self = bless {}, $self; 8: 9: return $self; 10: } The hash %p contains any values passed to the "Alzabo::RDBMSRules->new" method by its caller. Lines 1-7 should probably be copied verbatim into your own "new" method. Line 5 can be deleted if you don't need to look at the parame- ters. The rest of your module should simply implement the methods listed under the "Virtual Methods" section of this documentation. Look at the included "Alzabo::RDBMSRules" subclasses for examples. Feel free to contact me for further help if you get stuck. Please tell me what database you're attempting to implement, and include the code you've written so far. AUTHOR
Dave Rolsky, <dave@urth.org> perl v5.8.8 2007-12-23 Alzabo::RDBMSRules(3pm)
All times are GMT -4. The time now is 01:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy