Sponsored Content
Top Forums Shell Programming and Scripting sed parse a lign into a new sql file Post 302546205 by sundaygeek on Wednesday 10th of August 2011 04:15:05 PM
Old 08-10-2011
oups, indeed....
can i optimize?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To parse through the file and print output using awk or sed script

suppose if u have a file like that Hen ABCCSGSGSGJJJJK 15 Cock ABCCSGGGSGIJJJL 15 * * * * * * : * * * . * * * : Hen CFCDFCSDFCDERTF 30 Cock CHCDFCSDHCDEGFI 30 * . * * * * * * * : * * :* : : . The output shud be where there is : and . It shud... (4 Replies)
Discussion started by: cdfd123
4 Replies

2. Shell Programming and Scripting

SED + Regex + SQL Input file

Here's the problem... I have a mysqldump file and I need to put single quotes around the date/time timestamp. So for example I have a line like: INSERT INTO attachments VALUES (1,182,2004-08-06 09:24:04,'description'... and I need it to become INSERT INTO attachments VALUES... (10 Replies)
Discussion started by: primal
10 Replies

3. Shell Programming and Scripting

sed command to parse Apache config file

Hi there, am trying to parse an Apache 'server' config file. A snippet of the config file is shown below: ..... ProxyPassReverse /foo http://foo.example.com/bar ..... ..... RewriteRule ^/(.*) http://www.example.com/$1 RewriteRule /redirect https://www.example1.com/$1 ........ (7 Replies)
Discussion started by: jy2k7ca
7 Replies

4. Shell Programming and Scripting

sed parse small xml file

I have a tmp.xml file like: <?xml version="1.0" encoding="UTF-8"?> <Response> <Ip>193.143.121.198</Ip> <Status>OK</Status> <CountryCode>PL</CountryCode> <CountryName>Poland</CountryName> <RegionCode>82</RegionCode> <RegionName>Pomorskie</RegionName> <City>Gdansk</City> ... (9 Replies)
Discussion started by: unclecameron
9 Replies

5. Shell Programming and Scripting

formating sql file using awk or sed

Hi, I have a file where I would like to add a prompt type object_name statement before every create commnad create or replace force view test_view_01 ( col1 col2 col3 ) as (select a,b,c from sometable ); create or replace view test_view_02 ( col4 col5 col6 ) as (5 Replies)
Discussion started by: jville
5 Replies

6. Shell Programming and Scripting

script to parse text file into sql commands

Hello all, I tried searching for something similiar before posting but couldn't come up with anything that fit what I need. In Linux, I'm trying to parse through a number of files and take the info in them and put it into mysql. My file is a dump from an expect script: ---filename... (3 Replies)
Discussion started by: hamanjam
3 Replies

7. Shell Programming and Scripting

Sed to parse log file

Hi all, thanks for reading the post. I'm trying to parse hundreds of log files in a directory. One log file looks similar to below: Investigator : Jim_Foo Custodian : Jim_Foo-HDD1-FOO-1234 Export Path : N:\FOO-1234\Foo_Foo Compute MD5 : No File List Only: No Extensions Selected:... (4 Replies)
Discussion started by: chipperuga
4 Replies

8. Shell Programming and Scripting

sql dump file - how to get certain values using sed

Hi, I have a dumpfile.sql - ========Start of file================= CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysql` /*!40100 DEFAULT CHARACTER SET latin1 */; CREATE TABLE `test_table1` ( `id` int ) AUTO_INCREMENT=12 CREATE TABLE `test_table2` ( `id` int ) AUTO_INCREMENT=120... (5 Replies)
Discussion started by: ashokvpp
5 Replies

9. Shell Programming and Scripting

Parse SQL text and only format first SELECT statement.

Hi Forum. Need your expertise on the following question. I have the following file which I would like to parse, find first block of SELECT statment and concatenate all input fields as 1 field (~ delimited): Old File: SELECT /*+ USE_HASH(CCOMM ICAR IMAP IAS IP IMAS IMPS IAP SPCA) */ ... (5 Replies)
Discussion started by: pchang
5 Replies

10. Programming

Parse with SQL

I am trying to parse a string using SQL but am too new and still learning. I have text in a control or field 685 that is variable, but always the same format. field 685 input arr 2q33.3q34(200,900,700-209,000,000)x2 xxx Desired output 2:200900700-209000000 Basically, the # after the... (2 Replies)
Discussion started by: cmccabe
2 Replies
Regexp::Optimizer(3pm)					User Contributed Perl Documentation				    Regexp::Optimizer(3pm)

NAME
Regexp::Optimizer - optimizes regular expressions SYNOPSIS
use Regexp::Optimizer; my $o = Regexp::Optimizer->new; my $re = $o->optimize(qr/foobar|fooxar|foozap/); # $re is now qr/foo(?:[bx]ar|zap)/ ABSTRACT
This module does, ahem, attempts to, optimize regular expressions. INSTALLATION
To install this module type the following: perl Makefile.PL make make test make install DESCRIPTION
Here is a quote from perltodo. Factoring out common suffices/prefices in regexps (trie optimization) Currently, the user has to optimize "foo|far" and "foo|goo" into "f(?:oo|ar)" and "[fg]oo" by hand; this could be done automatically. This module implements just that. EXPORT Since this is an OO module there is no symbol exported. METHODS
This module is implemented as a subclass of Regexp::List. For methods not listed here, see Regexp::List. $o = Regexp::Optimizer->new; $o->set(key => value, ...) Just the same us Regexp::List except for the attribute below; unexpand When set to one, $o->optimize() tries to $o->expand before actually starting the operation. # cases you need to set expand => 1 $o->set(expand => 1)->optimize(qr/ foobar| fooxar| foozar /x); $re = $o->optimize(regexp); Does the job. Note that unlike "->list2re()" in Regexp::List, the argument is the regular expression itself. What it basically does is to find groups will alterations and replace it with the result of "$o->list2re". $re = $o->list2re(list of words ...) Same as "list2re()" in Regexp::List in terms of functionality but how it tokenize "atoms" is different since the arguments can be regular expressions, not just strings. Here is a brief example. my @expr = qw/foobar fooba+/; Regexp::List->new->list2re(@expr) eq qr/fooba[+r]/; Regexp::Optimizer->new->list2re(@expr) eq qr/foob(?:a+ar)/; CAVEATS
This module is still experimental. Do not assume that the result is the same as the unoptimized version. o When you just want a regular expression which matches normal words with not metacharacters, use <Regexp::List>. It's more robus and much faster. o When you have a list of regular expessions which you want to aggregate, use "list2re" of THIS MODULE. o Use "->optimize()" when and only when you already have a big regular expression with alterations therein. "->optimize()" does support nested groups but its parser is not tested very well. BUGS
o Regex parser in this module (which itself is implemented by regular expression) is not as thoroughly tested as Regexp::List o May still fall into deep recursion when you attempt to optimize deeply nested regexp. See "PRACTICALITY". o Does not grok (?{expression}) and (?(cond)yes|no) constructs yet o You need to escape characters in character classes. $o->optimize(qr/[a-z()]|[A-Z]/); # wrong $o->optimize(qr/[a-z()]|[A-Z]/); # right $o->optimize(qr/[0-9A-Za-z]|[Q-_.!~*"'()E]/ # right, too. o When character(?: class(?:es)?)? are aggregated, duplicate ranges are left as is. Though functionally OK, it is cosmetically ugly. $o->optimize(qr/[0-5]|[5-9]|0123456789/); # simply turns into [0-5][5-9]0123456789] not [0-9] I left it that way because marking-rearranging approach can result a humongous result when unicode characters are concerned (and p{Properties}). PRACTICALITY
Though this module is still experimental, It is still good enough even for such deeply nested regexes as the followng. # See 3.2.2 of http://www.ietf.org/rfc/rfc2616.txt # BNF faithfully turned into a regex http://(?:(?:(?:(?:(?:[a-z]|[A-Z])|[0-9])|(?:(?:[a-z]|[A-Z])|[0-9])(?:(?:(?:[a-z]|[A-Z])|[0-9])|-)*(?:(?:[a-z]|[A-Z])|[0-9])).)*(?:(?:[a-z]|[A-Z])|(?:[a-z]|[A-Z])(?:(?:(?:[a-z]|[A-Z])|[0-9])|-)*(?:(?:[a-z]|[A-Z])|[0-9])).?|[0-9]+.[0-9]+.[0-9]+.[0-9]+)(?::[0-9]*)?(?:/(?:(?:(?:(?:[a-z]|[A-Z])|[0-9])|[-\_.!~*'()])|%(?:[0-9]|[A-Fa-f])(?:[0-9]|[A-Fa-f])|[:@&=+$,])*(?:;(?:(?:(?:(?:[a-z]|[A-Z])|[0-9])|[-\_.!~*'()])|%(?:[0-9]|[A-Fa-f])(?:[0-9]|[A-Fa-f])|[:@&=+$,])*)*(?:/(?:(?:(?:(?:[a-z]|[A-Z])|[0-9])|[-\_.!~*'()])|%(?:[0-9]|[A-Fa-f])(?:[0-9]|[A-Fa-f])|[:@&=+$,])*(?:;(?:(?:(?:(?:[a-z]|[A-Z])|[0-9])|[-\_.!~*'()])|%(?:[0-9]|[A-Fa-f])(?:[0-9]|[A-Fa-f])|[:@&=+$,])*)*)*(?:\?(?:[;/?:@&=+$,]|(?:(?:(?:[a-z]|[A-Z])|[0-9])|[-\_.!~*'()])|%(?:[0-9]|[A-Fa-f])(?:[0-9]|[A-Fa-f]))*)?)? # and optimized http://(?::?[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?.[a-zA-Z]*(?:[a-zA-Z0-9-]*[a-zA-Z0-9])?.?|[0-9]+.[0-9]+.[0-9]+.[0-9]+)(?::[0-9]*)?(?:/(?:(?:(?:[a-zA-Z0-9-\_.!~*'x28x29]|%[0-9A-Fa-f][0-9A-Fa-f])|[:@&=+$,]))*(?:;(?:(?:(?:[a-zA-Z0-9-\_.!~*'x28x29]|%[0-9A-Fa-f][0-9A-Fa-f])|[:@&=+$,]))*)*(?:/(?:(?:(?:[a-zA-Z0-9-\_.!~*'x28x29]|%[0-9A-Fa-f][0-9A-Fa-f])|[:@&=+$,]))*(?:;(?:(?:(?:[a-zA-Z0-9-\_.!~*'x28x29]|%[0-9A-Fa-f][0-9A-Fa-f])|[:@&=+$,]))*)*)*(?:\?(?:(?:[;/?:@&=+$,a-zA-Z0-9-\_.!~*'x28x29]|%[0-9A-Fa-f][0-9A-Fa-f]))*)?)? By carefully examine both you can find that character classes are properly aggregated. SEE ALSO
Regexp::List -- upon which this module is based "eg/" directory in this package contains example scripts. Perl standard documents L<perltodo>, L<perlre> CPAN Modules Regexp::Presuf, Text::Trie Books Mastering Regular Expressions <http://www.oreilly.com/catalog/regex2/> AUTHOR
Dan Kogai <dankogai@dan.co.jp> COPYRIGHT AND LICENSE
Copyright 2003 by Dan Kogai This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2004-12-05 Regexp::Optimizer(3pm)
All times are GMT -4. The time now is 02:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy