Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: UNIX help needed for sed multi-line pattern space
<SPAN
class=224564123-15112001>Alan,
<SPAN
class=224564123-15112001>
<SPAN
class=224564123-15112001>Why not use awk?
<SPAN
class=224564123-15112001>
<SPAN
class=224564123-15112001>cat filename | awk '{if (
substr($0,length($0),1) == ";") {print " " $0 } else {printf($0)
}}'
<SPAN
class=224564123-15112001>
<SPAN
class=224564123-15112001>Hope this helps
<SPAN
class=224564123-15112001>
<SPAN
class=224564123-15112001>Chris
<SPAN
class=224564123-15112001>
<SPAN
class=224564123-15112001>
<FONT face=Tahoma
size=2>-----Original Message-----From: Martin, Alan
[mailto:amartin_at_dlis.dla.mil]Sent: 15 November 2001
17:55To: Multiple recipients of list ORACLE-LSubject:
UNIX help needed for sed multi-line pattern space
If I have the following two-line sql statement in a
file:
SELECT A,B,C FROM TABLE1 <FONT
face=Arial size=2>WHERE A=1;
and want to create a single line, I could use the
following sed script:
/[^;]$/{ <FONT face=Arial
size=2> N s/\n/ /
}
which would produce:
SELECT A,B,C FROM TABLE1 WHERE A=1;
What would my sed script look like if there were 2,
3, or even 4 continuation lines (unknown number of lines)? <FONT
face=Arial size=2>Note that the file is too large for vi. <FONT
face=Arial size=2>Any good UNIX sites where I could post UNIX
questions?
Thanx,
Alan
Martin <FONT color=#000000 face="Albertus Extra Bold"
size=2>Principal Consultant <FONT color=#000000 face=Arial
size=2>Defense Logistics Information Service <FONT
color=#0000ff face="Courier New" size=2>amartin_at_dlis.dla.mil
Received on Thu Nov 15 2001 - 17:53:31 CST
![]() |
![]() |