Sponsored Content
Top Forums Shell Programming and Scripting Search a character and replace it with multiple lines Post 302918256 by Mukul Sharma on Monday 22nd of September 2014 02:23:37 PM
Old 09-22-2014
Search a character and replace it with multiple lines

This is for AIX 6.1, I've a flat file and the format is like this

Code:
DECLARE
    some statements;

BEGIN

    some statements;

END;

I've to search BEGIN and replace it with the following 4 lines
Code:
BEGIN
For x in 1..1
LOOP
BEGIN

Similarly I've to search END and replace it with the following text in 6 lines. I cannot combine lines and I need to put semi colon at the end as mentioned below in certain lines.

Code:
EXCEPTION 
	when DUP_VAL_ON_INDEX then
		continue;
END;
END LOOP;
END;

Can you please help?

Thanks

Mukul

Last edited by Corona688; 09-22-2014 at 03:53 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace a perticular character of all lines of a file

Hi all, I am new to UNIX, so sorry if my question seem stupid to u. well i want to replace the first character of first 30 lines of a file, only if the first character is h. and in anothe script i want to replace a particular string/character say hello/h of a file.Condition: It should... (1 Reply)
Discussion started by: abovais
1 Replies

2. Shell Programming and Scripting

Need to search and replace based on character count

Hi, I wanted to add a newline character after every 100 characters in a file using a awk or shell without reading each line of the file. I want to run a command on the complete file. This does based on a string but i want to add a new line after every 100 characters ir-respective of the... (3 Replies)
Discussion started by: vijaykrc
3 Replies

3. UNIX for Dummies Questions & Answers

vi Search for text, Replace with <CR> or control character.

Greetings, Using vi, how can I change the following text: -I/myviews/nexus_7400rel/vobs/nexus/platforms/97400/include -I/myviews/nexus_7400rel/vobs/nexus/modules/i2c/7400/include -I/myviews/nexus_7400rel/vobs/nexus/modules/surface/7400/include Into this:... (4 Replies)
Discussion started by: omega949
4 Replies

4. Shell Programming and Scripting

Replace multiple occurances of same character with a single character.

Hi all, Greetings, I have the following scenario, The contents of main file are like : Unix|||||forum|||||||||||||||is||||||the||best so||||||be|||||on||||||||||||||||||||||||||||||||||||||||||||it And i need the output in the following form: Unix=forum=is=the=best so=be=on=it ... (3 Replies)
Discussion started by: dipanchandra
3 Replies

5. Shell Programming and Scripting

search and replace, when found, delete multiple lines, add new set of lines?

hey guys, I tried searching but most 'search and replace' questions are related to one liners. Say I have a file to be replaced that has the following: $ cat testing.txt TESTING AAA BBB CCC DDD EEE FFF GGG HHH ENDTESTING This is the input file: (3 Replies)
Discussion started by: DeuceLee
3 Replies

6. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies

7. Shell Programming and Scripting

Search & Replace: Multiple Strings / Multiple Files

I have a list of files all over a file system e.g. /home/1/foo/bar.x /www/sites/moose/foo.txtI'm looking for strings in these files and want to replace each occurrence with a replacement string, e.g. if I find: '#@!^\&@ in any of the files I want to replace it with: 655#@11, etc. There... (2 Replies)
Discussion started by: spacegoose
2 Replies

8. Shell Programming and Scripting

Regex:search/replace but not for escaped character

Hi Input: - -- --- ---- aa-bb-cc aa--bb--cc aa---bb---cc aa----bb----cc Output: . - -. -- aa.bb.cc (7 Replies)
Discussion started by: chitech
7 Replies

9. UNIX for Dummies Questions & Answers

Search for a particular word and replace the first character

Hi Unix gurus, I've a dna sequence in a file format known as fasta format (sequence header starts with > and ignored), an example shown below: >sequence_1 CGTATTCTCCGAATACC ATACG >sequence_2 CAGATTTTCAAATACCCCC In a file like this I want to do the following three search and replace. The... (4 Replies)
Discussion started by: Fahmida
4 Replies

10. UNIX for Dummies Questions & Answers

Replace character in odd or even lines

Hello, I'm here again asking for your precious help. I'm writing some code to convert csv files to html. I want to highlight header and also I want to have rows with alternate colors. So far this is my work###Let's format first line only with some color cat $fileIN".tmp1" | sed '1... (7 Replies)
Discussion started by: emare
7 Replies
DO(7)							  PostgreSQL 9.2.7 Documentation						     DO(7)

NAME
DO - execute an anonymous code block SYNOPSIS
DO [ LANGUAGE lang_name ] code DESCRIPTION
DO executes an anonymous code block, or in other words a transient anonymous function in a procedural language. The code block is treated as though it were the body of a function with no parameters, returning void. It is parsed and executed a single time. The optional LANGUAGE clause can be written either before or after the code block. PARAMETERS
code The procedural language code to be executed. This must be specified as a string literal, just as in CREATE FUNCTION. Use of a dollar-quoted literal is recommended. lang_name The name of the procedural language the code is written in. If omitted, the default is plpgsql. NOTES
The procedural language to be used must already have been installed into the current database by means of CREATE LANGUAGE. plpgsql is installed by default, but other languages are not. The user must have USAGE privilege for the procedural language, or must be a superuser if the language is untrusted. This is the same privilege requirement as for creating a function in the language. EXAMPLES
Grant all privileges on all views in schema public to role webuser: DO $$DECLARE r record; BEGIN FOR r IN SELECT table_schema, table_name FROM information_schema.tables WHERE table_type = 'VIEW' AND table_schema = 'public' LOOP EXECUTE 'GRANT ALL ON ' || quote_ident(r.table_schema) || '.' || quote_ident(r.table_name) || ' TO webuser'; END LOOP; END$$; COMPATIBILITY
There is no DO statement in the SQL standard. SEE ALSO
CREATE LANGUAGE (CREATE_LANGUAGE(7)) PostgreSQL 9.2.7 2014-02-17 DO(7)
All times are GMT -4. The time now is 04:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy