Sponsored Content
Top Forums Shell Programming and Scripting How to extract block from a file? Post 302519471 by Mac91 on Wednesday 4th of May 2011 05:44:15 AM
Old 05-04-2011
I want to know the use of system function in linux and also the difference between system() and backtrick term?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

extract block in file

I need to extract a particular block from a file whose locations are not known but the only identity is a word. For example in a file I have ABC asdklf asdfk FGH dfdfg asdlfk asdfl ... JHK (5 Replies)
Discussion started by: sskb
5 Replies

2. Shell Programming and Scripting

Extract block of data and the error reason too. So so urgent

Hi , this is my first enty in our forum. Problem scenario: Using informatica tool am loding records from source DB to target DB. While loading some records getting rejected due to some reason. Informatica will capture those rejected records in session log file.now the session log ll be... (2 Replies)
Discussion started by: Gopal_Engg
2 Replies

3. Shell Programming and Scripting

Extract selective block from XML file

Hi, There's an xml file produced from a front-end tool as shown below: <INPUT DATABASE ="ORACLE" DBNAME ="UNIX" NAME ="FACT_TABLE" OWNERNAME ="DIPS"> <INPUTFIELD DATATYPE ="double" DEFAULTVALUE ="" DESCRIPTION ="" NAME ="STORE_KEY" PICTURETEXT ="" PORTTYPE ="INPUT" PRECISION ="15" SCALE... (6 Replies)
Discussion started by: dips_ag
6 Replies

4. Shell Programming and Scripting

Extract a block of text??

Hello all, I have a large output file from which I would like to extract a single block of text. An example block of text is shown below: ***** EQUILIBRIUM GEOMETRY LOCATED ***** COORDINATES OF ALL ATOMS ARE (ANGS) ATOM CHARGE X Y Z ... (10 Replies)
Discussion started by: marcozd
10 Replies

5. Shell Programming and Scripting

[Awk] Extract block of with a particular pattern

Hi, I have some CVS log files, which are divided into blocks. Each block has many fields of information and I want to extract those blocks with a pattern. Here is the sample input. RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java,v head: 1.174... (7 Replies)
Discussion started by: sandeepk1611
7 Replies

6. UNIX for Advanced & Expert Users

Move a block of lines to file if string found in the block.

I have a "main" file which has blocks of data for each user defined by tags BEGIN and END. BEGIN ID_NUM:24879 USER:abc123 HOW:47M CMD1:xyz1 CMD2:arp2 STATE:active PROCESS:id60 END BEGIN ID_NUM:24880 USER:def123 HOW:4M CMD1:xyz1 CMD2:xyz2 STATE:running PROCESS:id64 END (7 Replies)
Discussion started by: grep_me
7 Replies

7. Shell Programming and Scripting

Printing a block of lines from a file, if that block does not contain two patterns using sed

I want to process a file block by block using sed, and if that block does not contain two patterns, then that complete block has to be printed. See below for the example data. ................................server 1............................... running process 1 running... (8 Replies)
Discussion started by: Kesavan
8 Replies

8. Shell Programming and Scripting

Extract a block of text

Hello all, I am working on a script which should parse a large file called input.txt which contains table definitions, index definitions and comments like these ones: ------------------------------------------------ -- DDL Statements for table "CMWSYS"."CMWD_TEC_SUIVI_TRT"... (12 Replies)
Discussion started by: kiki_riki_miki
12 Replies

9. Shell Programming and Scripting

How can I extract XML block around matching search string?

I want to extract XML block surrounding search string Ex: print XML block for string "myapp1-ear" surrounded by "<application> .. </application>" Input XML: <?xml version="1.0" encoding="UTF-8"?> <deployment-request> <requestor> <first-name>kchinnam</first-name> ... (16 Replies)
Discussion started by: kchinnam
16 Replies

10. UNIX for Beginners Questions & Answers

Extract XML block when value is matched (Shell script)

Hi everyone, So i'm struggling with an xml (log file) where we get information about some devices, so the logfile is filled with multiple "blocks" like that. Based on the <devId> i want to extract this part of the xml file. If possible I want it to have an script for this, cause we'll use... (5 Replies)
Discussion started by: Pouky
5 Replies
README(3pm)						User Contributed Perl Documentation					       README(3pm)

NAME
DBIx::DR - easy DBI helper (perl inside SQL and blessed results) SYNOPSIS
my $dbh = DBIx::DR->connect($dsn, $login, $passed); $dbh->perform( 'UPDATE tbl SET a = 1 WHERE id = <%= $id %>', id => 123 ); my $rowset = $dbh->select( 'SELECT * FROM tbl WHERE id IN (<% list @$ids %>)', ids => [ 123, 456 ] ); my $rowset = $dbh->select(-f => 'sqlfile.sql.ep', ids => [ 123, 456 ]); while(my $row = $rowset->next) { print "id: %d, value: %s ", $row->id, $row->value; } DESCRIPTION
The package extends DBI and allows You: o to use perl inside Your SQL requests; o to bless resultsets into Your package; o to place Your SQL's into dedicated directory; o to use usual DBI methods. Additional 'connect' options. dr_iterator A string describes iterator class. Default value is 'dbix-dr-iterator#new' (decamelized string). dr_item A string describes item (one row) class. Default value is 'dbix-dr-iterator-item#new' (decamelized string). dr_sql_dir Directory path to seek sql files (If You use dedicated SQLs). dr_decode_errors Decode database errors into utf-8 METHODS
All methods can receive the following arguments: -f => $sql_file_name It will load SQL-request from file. It will seek file in directory that was defined in dr_sql_dir param of connect. You needn't to use suffixes (.sql.ep) here, but You can. -item => 'decamelized_obj_define' It will bless (or construct) row into specified class. See below. Default value defined by dr_item argument of DBI::connect. -noitem Do not bless row into any class. -iterator => 'decamelized_obj_define' It will bless (or construct) rowset into specified class. Default value defined by dr_iterator argument of DBI::connect. -noiterator Do not bless rowset into any class. -dbi => HASHREF Additional DBI arguments. -hash => FIELDNAME Selects into HASH. Iterator will operate by names (not numbers). Decamelized strings Are strings that represent class [ and method ]. foo_bar => FooBar foo_bar#subroutine => FooBar->subroutine foo_bar-baz => FooBar::Baz perform Does SQL-request like 'UPDATE', 'INSERT', etc. $dbh->perform($sql, value => 1, other_value => 'abc'); $dbh->perform(-f => $sql_file_name, value => 1, other_value => 'abc'); select Does SQL-request, pack results into iterator class. By default it uses DBIx::DR::Iterator class. my $res = $dbh->select(-f => $sql_file_name, value => 1); while(my $row = $res->next) { printf "RowId: %d, RowValue: %s ", $row->id, $row->value; } my $row = $row->get(15); # row 15 my $res = $dbh->select(-f => $sql_file_name, value => 1, -hash => 'name'); while(my $row = $res->next) { printf "RowId: %d, RowName: %s ", $row->id, $row->name; } my $row = $row->get('Vasya'); # row with name eq 'Vasya' single Does SQL-request that returns one row. Pack results into item class. Does SQL-request, pack results (one row) into item class. By default it uses DBIx::DR::Iterator::Item class. Template language You can use perl inside Your SQL requests: % my $foo = 1; % my $bar = 2; <% my $foo_bar = $foo + $bar %> .. % use POSIX; % my $gid = POSIX::getgid; There are two functions available inside perl: quote Replaces argument to '?', add argument value into bindlist. You can also use shortcut '=' instead of the function. Example 1 SELECT * FROM tbl WHERE id = <% quote $id %> Result SELECT * FROM tbl WHERE id = ? and bindlist will contain id value. If You use DBIx::DR::ByteStream in place of string the function will recall immediate function. Example 2 SELECT * FROM tbl WHERE id = <%= $id %> immediate Replaces argument to its value. You can also use shortcut '==' instead of the function. Example 1 SELECT * FROM tbl WHERE id = <% immediate $id %> Result SELECT * FROM tbl WHERE id = 123 Where 123 is id value. Be carful! Using the operator You can produce code that will be amenable to SQL-injection. Example 2 SELECT * FROM tbl WHERE id = <%== $id %> Helpers There are a few default helpers. list Expands array into Your SQL request. Example SELECT * FROM tbl WHERE status IN (<% list @$ids %>) Result SELECT * FROM tbl WHERE status IN (?,?,? ...) and bindlist will contain ids values. hlist Expands array of hash into Your SQL request. The first argument can be a list of required keys. Places each group into brackets. Example INSERT INTO tbl ('a', 'b') VALUES <% hlist ['a', 'b'] => @$inserts Result INSERT INTO tbl ('a', 'b') VALUES (?, ?), (?, ?) ... and bindlist will contain all inserts values. include Includes the other SQL-part. Example % include 'other_sql', argument1 => 1, argument2 => 2; User's helpers You can add Your helpers using method set_helper. set_helper Sets (or replaces) helpers. $dbh->set_helper(foo => sub { ... }, bar => sub { ... }); Each helper receives template object as the first argument. Examples: $dbh->set_helper(foo_AxB => sub { my ($tpl, $a, $b) = @_; $tpl->quote($a * $b); }); You can use quote and immediate functions inside Your helpers. If You want use the other helper inside Your helper You have to do that by Yourself. To call the other helper You can also use "$tpl->call_helper" function. call_helper $dbh->set_helper( foo => sub { my ($tpl, $a, $b) = @_; $tpl->quote('foo' . $a . $b); }, bar => sub { my $tpl = shift; $tpl->call_helper(foo => 'b', 'c'); } ); COPYRIGHT
Copyright (C) 2011 Dmitry E. Oboukhov <unera@debian.org> Copyright (C) 2011 Roman V. Nikolaev <rshadow@rambler.ru> This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License. VCS
The project is placed git repo on github: https://github.com/unera/dbix-dr/ <https://github.com/unera/dbix-dr/> perl v5.14.2 2012-05-11 README(3pm)
All times are GMT -4. The time now is 07:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy