Sponsored Content
Full Discussion: Replace Block
Top Forums Shell Programming and Scripting Replace Block Post 302445239 by clem.explisit on Saturday 14th of August 2010 06:41:06 PM
Old 08-14-2010
A little bit simple solution :

Code:
cat $file | grep -A $nb_line_to_suppress "$motif" > /tmp/tempfile.tmp
diff --suppress-common-lines --unchanged-line-format='' $file /tmp/tempfile.tmp > file.suppressed_block
rm -f /tmp/tempfile.tmp

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Search/replace using visual block

Hi, how would we replace a few patterns on the same line with a change of it's own..using visual block on vim editor. ie a file contains lines such as the following: abccss (dfrss)) emailkk abdcss (dfrss)) dmailkk Using visual block once, replacement is indeed to get the following output:... (0 Replies)
Discussion started by: Manan
0 Replies

2. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

3. Shell Programming and Scripting

finding a block in a file and replace with another file block.

(1) Yes but how is this block different from the other 24? You will need this information in order to identify and replace this block correctly (out of the 25). Ans: The 1st line and last line of this block are unique from other block. The 1st line is “rem Subset Rows (&&tempName.*) and The... (1 Reply)
Discussion started by: Zaheer.mic
1 Replies

4. Shell Programming and Scripting

Need to find a multiple line block and replace with a multiple line block

I would perfer to use cut and paste to do this but I can't find a GUI to do this with. What I want to do is to find a multiple line block of code like Exit Sub Log_Handler: then replace it with GoTo RSLogRtn Exit Sub Log_Handler: Basically it is just an insert, but I may want to... (8 Replies)
Discussion started by: Randem
8 Replies

5. Shell Programming and Scripting

Replace text block in multiple files

I need to replace (delete) a text block in a bunch of files, its a html table, almost at the end of pages but the location varies. In Windows I used Filemonkey, but nothing like that in Unix? There is replace from mysql, but how does it deal with newlines? sed only works with single lines,... (6 Replies)
Discussion started by: eiland
6 Replies

6. Shell Programming and Scripting

replace block of text with content of another file

Hello, file1: not to be changed not to be changed <start> old stuff old stuff old stuff <end> not to be changed not to be changed file2: new text new text desired output: (3 Replies)
Discussion started by: ripat
3 Replies

7. Shell Programming and Scripting

using sed/awk to replace a block of text in a file?

My apologies if this has been answered in a previous post. I've been doing a lot of searching, but I haven't been able to find what I was looking for. Specifically, I am wondering if I can utilize sed and/or awk to locate two strings in a file, and replace everything between those two strings... (12 Replies)
Discussion started by: kiddsupreme
12 Replies

8. 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

9. Shell Programming and Scripting

Bash shell: Replace a text block by another

Hello, I'm an starter in Bash scripting. I would like to write a script in Bash shell that replaces a specific text block (a function) by another text block in a file: for example in my file --> $HOME/myFile.js replacing following function between other functions in the file: function ABC()... (6 Replies)
Discussion started by: om1559
6 Replies

10. UNIX for Beginners Questions & Answers

awk script to extract a column, replace one of the header and replace year(from ddmmyy to yyyy)

I have a csv which has lot of columns . I was looking for an awk script which would extract a column twice. for the first occurance the header and data needs to be intact but for the second occurance i want to replace the header name since it a duplicate and extract year value which is in ddmmyy... (10 Replies)
Discussion started by: Kunalcurious
10 Replies
HTML::FormFu::Element::Repeatable(3pm)			User Contributed Perl Documentation		    HTML::FormFu::Element::Repeatable(3pm)

NAME
HTML::FormFu::Element::Repeatable - repeatable block element SYNOPSIS
--- elements: - type: Repeatable name: my_rep elements: - name: foo - name: bar Calling "$element->repeat(2)" would result in the following markup: <div> <input name="my_rep.foo_1" type="text" /> <input name="my_rep.bar_1" type="text" /> </div> <div> <input name="my_rep.foo_2" type="text" /> <input name="my_rep.bar_2" type="text" /> </div> Example of constraints: ---- elements: - type: Repeatable name: my_rep elements: - name: id - name: foo constraints: - type: Required when: field: 'my_rep.id' # use full nested-name - name: bar constraints: - type: Equal others: 'my_rep.foo' # use full nested-name DESCRIPTION
Provides a way to extend a form at run-time, by copying and repeating its child elements. The elements intended for copying must be added before "repeat" is called. Although the Repeatable element inherits from Block, it doesn't generate a block tag around all the repeated elements - instead it places each repeat of the elements in a new Block element, which inherits the Repeatable's display settings, such as "attributes" and "tag". For all constraints attached to fields within a Repeatable block which use either others or when containing names of fields within the same Repeatable block, when repeat is called, those names will automatically be updated to the new nested-name for each field (taking into account increment_field_names). METHODS
repeat Arguments: [$count] Return Value: $arrayref_of_new_child_blocks This method creates $count number of copies of the child elements. If no argument $count is provided, it defaults to 1. Note that "$form->process" will call "repeat" automatically to ensure the initial child elements are correctly set up - unless you call "repeat" manually first, in which case the child elements you created will be left untouched (otherwise process would overwrite your changes). Any subsequent call to "repeat" will delete the previously copied elements before creating new copies - this means you cannot make repeated calls to "repeat" within a loop to create more copies. Each copy of the elements returned are contained in a new Block element. For example, calling "$element->repeat(2)" on a Repeatable element containing 2 Text fields would return 2 Block elements, each containing a copy of the 2 Text fields. counter_name Arguments: $name If true, the "query" in HTML::FormFu will be searched during "process" in HTML::FormFu for a parameter with the given name. The value for that parameter will be passed to "repeat", to automatically create the new copies. If "increment_field_names" is true (the default), this is essential: if the elements corresponding to the new fieldnames (foo_1, bar_2, etc.) are not present on the form during "process" in HTML::FormFu, no Processors (Constraints, etc.) will be run on the fields, and their values will not be returned by "params" in HTML::FormFu or "param" in HTML::FormFu. increment_field_names Arguments: $bool Default Value: 1 If true, then all fields will have "_n" appended to their name, where "n" is the "repeatable_count" value. repeatable_count This is set on each new Block element returned by "repeat", starting at number 1. Because this is an 'inherited accessor' available on all elements, it can be used to determine whether any element is a child of a Repeatable element. Only available after repeat has been called. nested_name If the "nested_name" attribute is set, the naming scheme of the Repeatable element's children is switched to add the counter to the repeatable blocks themselves. --- elements: - type: Repeatable nested_name: my_rep elements: - name: foo - name: bar Calling "$element->repeat(2)" would result in the following markup: <div> <input name="my_rep_1.foo" type="text" /> <input name="my_rep_1.bar" type="text" /> </div> <div> <input name="my_rep_2.foo" type="text" /> <input name="my_rep_2.bar" type="text" /> </div> Because this is an 'inherited accessor' available on all elements, it can be used to determine whether any element is a child of a Repeatable element. attributes attrs Any attributes set will be passed to every repeated Block of elements. --- elements: - type: Repeatable name: my_rep attributes: class: rep elements: - name: foo Calling "$element->repeat(2)" would result in the following markup: <div class="rep"> <input name="my_rep.foo_1" type="text" /> </div> <div class="rep"> <input name="my_rep.foo_2" type="text" /> </div> See "attributes" in HTML::FormFu for details. tag The "tag" value will be passed to every repeated Block of elements. --- elements: - type: Repeatable name: my_rep tag: span elements: - name: foo Calling "$element->repeat(2)" would result in the following markup: <span> <input name="my_rep.foo_1" type="text" /> </span> <span> <input name="my_rep.foo_2" type="text" /> </span> See "tag" in HTML::FormFu::Element::Block for details. auto_id As well as the usual subtitutions, any instances of %r will be replaced with the value of "repeatable_count". See "auto_id" in HTML::FormFu::Element::Block for further details. --- elements: - type: Repeatable name: my_rep auto_id: "%n_%r" elements: - name: foo Calling "$element->repeat(2)" would result in the following markup: <div> <input name="my_rep.foo_1" id="foo_1" type="text" /> </div> <div> <input name="my_rep.foo_2" id="foo_2" type="text" /> </div> content Not supported for Repeatable elements - will throw a fatal error if called as a setter. CAVEATS
Unsupported Constraints Note that constraints with an others method do not work correctly within a Repeatable block. Currently, these are: AllOrNone, DependOn, Equal, MinMaxFields, reCAPTCHA. Also, the CallbackOnce constraint won't work within a Repeatable block, as it wouldn't make much sense. SEE ALSO
Is a sub-class of, and inherits methods from HTML::FormFu::Element::Block, HTML::FormFu::Element HTML::FormFu AUTHOR
Carl Franks, "cfranks@cpan.org" LICENSE
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-01-23 HTML::FormFu::Element::Repeatable(3pm)
All times are GMT -4. The time now is 12:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy