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
I've to search BEGIN and replace it with the following 4 lines
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.
Can you please help?
Thanks
Mukul
Last edited by Corona688; 09-22-2014 at 03:53 PM..
Welcome to forum, please use code tags while using putting commands and codes in post as per forum rules. Now for your post, could you please let us know the input and expected output, so that we may help you in same. Kindly make sure you are using code tags while putting commands and codes in post.
DECLARE
null_value CHAR(1) := NULL;
statement1 CHAR(63);
statement2 CHAR(56);
BEGIN
FOR X in 1..1
LOOP
BEGIN
statement1 := 'INSERT INTO rateheader VALUES (:0, :1, :2, :3, :4, :5, :6)';
END="
EXCEPTION
WHEN OTHERS THEN
CONTINUE;
END;
END LOOP;
/
Following is the fixed code, based on your own approach with sed, which did not work, I guess.
(I cannot guarantee it will work with AIX' version of sed, but it's worth to try, let me know) ---------- Post updated at 10:44 PM ---------- Previous update was at 10:40 PM ----------
Following is another approach, based on awk (note how no wild escaping is required):
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)
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)
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)
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)
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)
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)
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)
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)
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)