Sponsored Content
Full Discussion: Regexp and sed problem
Top Forums Shell Programming and Scripting Regexp and sed problem Post 302354625 by durden_tyler on Friday 18th of September 2009 11:50:47 PM
Old 09-19-2009
Using a different approach:

Code:
$ 
$ cat f1
DELETE FROM /*<workDB>*/epd_test./*<multi>*//*<version>*/epd_tbl1 ALL;
$ 
$ ##
$ perl -ne 'BEGIN{undef $/} chomp($m=$_); while(/\/\*<(.*?)>\*\//msg){push @x,$1}
>           END{$m =~ s#\*/.*?./\*#*/\${$x[0]}./*#;
>               $m =~ s#\*/([^*]*?) #*/\${$x[1]}\${$x[2]}_$1 #;
>               print $m;
>              }' f1
DELETE FROM /*<workDB>*/${workDB}./*<multi>*//*<version>*/${multi}${version}_epd_tbl1 ALL;
$ 
$ 
$ cat f2
DELETE FROM /*<abcDB>*/epd_test./*<multi>*//*<version>*/epd_tbl1 ALL;
$ 
$ ##
$ perl -ne 'BEGIN{undef $/} chomp($m=$_); while(/\/\*<(.*?)>\*\//msg){push @x,$1}
>           END{$m =~ s#\*/.*?./\*#*/\${$x[0]}./*#;
>               $m =~ s#\*/([^*]*?) #*/\${$x[1]}\${$x[2]}_$1 #;
>               print $m;
>              }' f2
DELETE FROM /*<abcDB>*/${abcDB}./*<multi>*//*<version>*/${multi}${version}_epd_tbl1 ALL;
$ 
$

tyler_durden
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

GnuWin32 sed 4.1.4 regexp matching

I am using GnuWin32 sed and am having trouble with the regexp - i.e., they don't behave the same way as in UNIX (POSIX and and all that). I have a stream of data, e.g.: 11111'222?'22'33?'333'44444'55555' I want to insert a \n after those apostrophes that are *not* preceded by a ?. ... (2 Replies)
Discussion started by: Simerian
2 Replies

2. Shell Programming and Scripting

regexp with sed again!!!

please help: I want to add 1 space between string and numbers: input file: abcd12345 output file: abcd 1234 The following sed command does not work: sed 's/\(+\)\(+\)/\1 \2/' file Any ideas, please Andy (2 Replies)
Discussion started by: andy2000
2 Replies

3. Shell Programming and Scripting

Help regarding behavior sed regexp query

Hi all, I have one question regarding sed regexp (or any regexp in general), I have some path like this C:/Abc/def/ghi/jkl in a file file1 Now if i use following code cat file1 | sed 's#\(.*\)/.*#\1#' Now it give me following output C:/Abc/def/ghi, which is fine But i just... (2 Replies)
Discussion started by: sarbjit
2 Replies

4. Shell Programming and Scripting

sed regexp

Hi, I am not that good with reg exp and sed. But I was just looking at something the other day and came across a situation. When I ran the below command: echo "123 word" | sed 's/*/(&)/' the op was: (123) word But when I ran: echo "123 word" | sed 's/*/(&)/g' the o/p was: (123)... (4 Replies)
Discussion started by: King Nothing
4 Replies

5. UNIX for Dummies Questions & Answers

sed before and after regexp

Dear all i have the code which print 1 line of context before and after regexp, with line number sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h the code work well but any one can tell me what each letter mean {=;x;1!p;g;$!N;p;D;} also how i can print 2 line before and onle line after ... (2 Replies)
Discussion started by: soly
2 Replies

6. Shell Programming and Scripting

Help with Regexp replace in vim/sed

Hi! I have a file with multiple lines following this format: <a href="xxx.aaa_bbb_ccc.yyy">xxx.aaa_bbb_ccc.yyy</a> The goal is to replace the title (not modifying the href) so the new lines looks like this: <a href="xxx.aaa_bbb_ccc.yyy">Aaa bbb ccc</a> The number of underscores in the... (2 Replies)
Discussion started by: ericjohansson
2 Replies

7. Shell Programming and Scripting

sed with multiple regexp

Dealing with Linux servers script would be in korn or bash shell syntax file is /etc/fstab I want to insert something if regex is matched to all matched lines in the /etc/fstab file and print out entire /etc/fstab file with the changes example 58.228.111.111:/my/file/system... (5 Replies)
Discussion started by: snoman1
5 Replies

8. Shell Programming and Scripting

Need help with sed and regexp

Hi everyone, I would really appreciate any help I could get on the following topic. I am not very familiar with reg expressions nor with sed, I just know the basic uses. What I am trying to do is the following: I have a huge text file where I would like to replace all occurnces of a certain... (13 Replies)
Discussion started by: Boxtuna
13 Replies

9. Shell Programming and Scripting

sed regexp teaser

G'day, Here's a teaser for a sed guru, which I surely am not one, as even my basic sed skills are rusted from years of not practising ... lol Ok ... we have a string of digits such as: 632413741610252847552619172459483022433027602515212950543016701812771409213148672112 we want it split... (9 Replies)
Discussion started by: naderra
9 Replies

10. UNIX for Beginners Questions & Answers

sed with regexp in Linux

OFF 00280456 - 2014|1|2020_STATUS|GROUP_NAME|SUBGROUP_NAME|CLASS_NAME|GROUP_ID|SUBGROUP_ID I have above header in file. I need to replace 2020_STATUS with STATUS. 2020_STATUS is not always same but the column name will have STATUS all of the time. For instance column name might be 2019_STATUS... (1 Reply)
Discussion started by: jmadhams
1 Replies
Arch::Changes(3pm)					User Contributed Perl Documentation					Arch::Changes(3pm)

NAME
Arch::Changes - class representing a list of changes SYNOPSIS
use Arch::Changes qw(:type); use Arch::Tree; my $changes = $tree->get_changes; print $changes->get_listing; use Arch::Log; my $changed = $log->get_changes->is_changed('to', "COPYING"); die "License was compromised" if $changed && $changed->{&MODIFY}; DESCRIPTION
Arch::Changes contains a list of elements, each representing a single tree change. Each change element is described by a hash with the following fields: type The type of the change. Can be one of ADD, DELETE, MODIFY, META_MODIFY or RENAME. is_dir A boolean value indicating whether the affected tree element is a directory. arguments A list of arguments. The first element is always relative path of the affected tree element. For changes of type RENAME the first argument is the old path and the second argument the new path name. The type constants can be conveniently imported using the tag ":type". use Arch::Changes qw(:type); METHODS
The following methods are available: new, add, count, get, get_listing, is_changed, dump, type_string, to_string. new Creates a new, initially empty, changes list. Typically it is called indirectly from method get_changes in Arch::Changeset, Arch::Tree or Arch::Log class. add type is_dir arguments... Adds a new change element to the list of changes. Typically it is called indirectly from method get_changes in Arch::Changeset, Arch::Tree or Arch::Log class. count Returns the number of change elements. get num Returns the num-th change element or all if num is undefined. get_listing Generates a textual changes listing as produced by "tla changes". is_changed to filepath [is_dir] Verify whether the given filepath is modified by the changes. The to parameter may get boolean values "0", "1", "from" or "to", it only affects RENAME changes, and in some sense ADD and DELETE changes. If to is set, then the given filepath is taken as the destination of RENAME or ADD, otherwise as the source of RENAME or DELETE. The MODIFY and META_MODIFY changes are not affected, since the destination and the source is the same file/dir. If filepath is not modified by any changes, return undef. Otherwise, return hash with possible keys ADD, DELETE, MODIFY, META_MODIFY and RENAME. The hash values are 1 in all cases except for RENAME, then the value is the file name on the opposite side (i.e., the source of RENAME if to is true, and the destination if false). Note, the valid return values for arch are: undef, hashref with one key (ADD or DELETE) or hashref with combination of one-to-three keys (MODIFY, META_MODIFY and RENAME). dump Generates a dump of the changes list using Data::Dumper. type_string change Returns the change type string as produced by "tla changes". to_string change Generates a changes line for change as produced by "tla changes". BUGS
Awaiting for your reports. AUTHORS
Mikhael Goikhman (migo@homemail.com--Perl-GPL/arch-perl--devel). Enno Cramer (uebergeek@web.de--2003/arch-perl--devel). SEE ALSO
For more information, see tla, Arch::Changeset, Arch::Tree, Arch::Log. perl v5.10.1 2005-10-23 Arch::Changes(3pm)
All times are GMT -4. The time now is 04:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy