Sponsored Content
Top Forums Shell Programming and Scripting awk to find pattern and add lines Post 302489362 by jpsingh on Thursday 20th of January 2011 09:53:06 AM
Old 01-20-2011
This won't match pattern on 2 lines but on 1 line, i.e. if I use:

Code:
 
sed 's/^SID_LIST_.*=$/& \
   (SID_LIST =\
    (SID_DESC =\
      (SID_NAME = <ORACLE_SID>)\
      (ORACLE_HOME = \/opt\/oracle\/product\/<ORACLE_SID>)\
      )/'

The output shall be:
Code:
SID_LIST_HOSTNAME_LISTENER_3 =
(SID_LIST =
(SID_DESC =
(SID_NAME = <ORACLE_SID>)
(ORACLE_HOME = /opt/oracle/product/<ORACLE_SID>)
)
(SID_LIST =
(SID_DESC =
(SID_NAME = ORA0008)
(ORACLE_HOME = /opt/oracle/product/ORA0008)
(ENVS = "LD_LIBRARY_PATH=/opt/oracle/product/ORA0008/lib")
)
(SID_DESC =
(SID_NAME = ORA0007)
...
...
etc.

Whereas I need:
Code:
SID_LIST_HOSTNAME_LISTENER_3 =
(SID_LIST =
(SID_DESC =
(SID_NAME = <ORACLE_SID>)
(ORACLE_HOME = /opt/oracle/product/<ORACLE_SID>)
)
(SID_DESC =
(SID_NAME = ORA0008)
(ORACLE_HOME = /opt/oracle/product/ORA0008)
(ENVS = "LD_LIBRARY_PATH=/opt/oracle/product/ORA0008/lib")
)
(SID_DESC =
(SID_NAME = ORA0007)
...
...

Any clues?

---------- Post updated at 08:23 PM ---------- Previous update was at 08:03 PM ----------

Thi works:

Code:
 
sed '/^SID_LIST_.*=$/,/(SID_LIST =$/ s/(SID_LIST =$/& \
    (SID_DESC =\
      (SID_NAME = <ORACLE_SID>)\
      (ORACLE_HOME = \/opt\/oracle\/product\/<ORACLE_SID>)\
      )/'


Last edited by Scott; 01-20-2011 at 12:05 PM.. Reason: More code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Joining lines and find pattern

I have a file that does not have much formatting. I would like every time it finds a tag (something that starts with < and end with > like <Tag1> ) to be at the beginning of the line and joined with the next line. I tried sed with append and can not get it right and also hold and get in sed... (4 Replies)
Discussion started by: quixoticking11
4 Replies

2. Shell Programming and Scripting

[Solved] Find duplicate and add pattern in sed/awk

<Update> I have the solution: sed 's/\{3\}/&;&;---;4/' The thread can be marked as solved! </Update> Hi There, I'm working on a script processing some data from a website into cvs format. There is only one final problem left I can't find a solution. I've processed my file... (0 Replies)
Discussion started by: lolworlds
0 Replies

3. Shell Programming and Scripting

[awk] find pattern, change next two lines

Hi, hope you can help me... It seems like a straightforward problem, but I haven't had any success so far using my basic scripting and awk "skills": I need to find a pattern /VEL/ in an input file that looks like this: 1110SOL OW25489 1.907 7.816 26.338 -0.4365 0.4100 -0.0736 ... (3 Replies)
Discussion started by: origamisven
3 Replies

4. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

5. Shell Programming and Scripting

awk to skip lines find text and add text based on number

I am trying to use awk skip each line with a ## or # and check each line after for STB= and if that value in greater than or = to 0.8, then at the end of line the text "STRAND BIAS" is written in else "GOOD". So in the file of 4 entries attached. awk tried: awk NR > "##"' "#" -F"STB="... (6 Replies)
Discussion started by: cmccabe
6 Replies

6. Shell Programming and Scripting

Using awk or sed to find a pattern that has lines before and after it

Dear gurus, Please help this beginner to write and understand the required script. I am looking for useing awk for sed. I have a few thousand lines file whose contain are mostly as below and I am trying to achieve followings. 1. Find a string, say user1. Then hash the line containing the... (6 Replies)
Discussion started by: ran_bon_78
6 Replies

7. Shell Programming and Scripting

Find pattern; grep n lines before and after

Hi, I need help to grep a specific part of a log file (bold). 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: } 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: extensionContainer <Not Present> 24/2/2017-16:57:17.056... (8 Replies)
Discussion started by: vasil
8 Replies

8. UNIX for Beginners Questions & Answers

find pattern matches in consecutive lines in certain fields-awk

I have a text file with many thousands of lines, a small sample of which looks like this: InputFile:PS002,003 D -1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 6 -1 -1 -1 -1 0 509 0 PS002,003 PSQ 0 1 7 18 1 0 -1 1 1 3 -1 -1 ... (5 Replies)
Discussion started by: jvoot
5 Replies

9. Shell Programming and Scripting

sed and awk to find pattern and add priffix

Original File Server1|poweredOn|268401| Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit) Need Output Server1|poweredOn|DR|T1|268401| Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit) Conduction to check find the string "SFCHT1" and "SR" and add prefix has... (4 Replies)
Discussion started by: ranjancom2000
4 Replies

10. UNIX for Beginners Questions & Answers

awk to remove pattern and lines above pattern

In the awk below I am trying to remove all lines above and including the pattern Test or Test2. Each block is seperated by a newline and Test2 also appears in the lines to keep but it will always have additional text after it. The Test to remove will not. The awk executed until the || was added... (2 Replies)
Discussion started by: cmccabe
2 Replies
PLMESH(3plplot) 						    PLplot API							   PLMESH(3plplot)

NAME
plmesh - Plot surface mesh SYNOPSIS
plmesh(x, y, z, nx, ny, opt) DESCRIPTION
Plots a surface mesh within the environment set up by plw3d(3plplot). The surface is defined by the two-dimensional array z[nx][ny], the point z[i][j] being the value of the function at (x[i], y[j]). Note that the points in arrays x and y do not need to be equally spaced, but must be stored in ascending order. The parameter opt controls the way in which the surface is displayed. For further details see the PLplot documentation. Redacted form: plmesh(x, y, z, opt) This function is used in example 11. ARGUMENTS
x (PLFLT *, input) Pointer to set of x coordinate values at which the function is evaluated. y (PLFLT *, input) Pointer to set of y coordinate values at which the function is evaluated. z (PLFLT **, input) Pointer to a vectored two-dimensional array with set of function values. nx (PLINT, input) Number of x values at which function is evaluated. ny (PLINT, input) Number of y values at which function is evaluated. opt (PLINT, input) Determines the way in which the surface is represented: opt=DRAW_LINEX: Lines are drawn showing z as a function of x for each value of y[j]. opt=DRAW_LINEY: Lines are drawn showing z as a function of y for each value of x[i]. opt=DRAW_LINEXY: Network of lines is drawn connecting points at which function is defined. AUTHORS
Geoffrey Furnish and Maurice LeBrun wrote and maintain PLplot. This man page was automatically generated from the DocBook source of the PLplot documentation, maintained by Alan W. Irwin and Rafael Laboissiere. SEE ALSO
PLplot documentation at http://plplot.sourceforge.net/resources. August, 2012 PLMESH(3plplot)
All times are GMT -4. The time now is 05:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy