HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need some sed magic
Operating System - HP-UX
1825759
Members
2203
Online
109687
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2008 10:53 AM
06-16-2008 10:53 AM
Hello shell gurus !
I am faced with an Oracle generated text file that contains SQL statements.
The file format is :
Statement semicolon newline
Statement semicolon newline
Statement semicolon newline
Due to a limitation of the generator the statements are written to the file in multiple passes, without regard for individual lines between passes. The result is a file that goes
Statement semicolon newline
Statement semicolon newline
Stat newline
ement semicolon newline
Statement semicolon newline
Statement semicolon newline
So I need to parse the file to find newlines not preceded by a semicolon and get rid of them.
I'm afraid this is beyond my current comfort level with the stream editor but I am convinced it can be done. I considered a multiple pass approach of removing all newlines and then substituting all semicolons with semicolon+newline but that is not elegant.
Your help is greatly appreciated !
I am faced with an Oracle generated text file that contains SQL statements.
The file format is :
Statement semicolon newline
Statement semicolon newline
Statement semicolon newline
Due to a limitation of the generator the statements are written to the file in multiple passes, without regard for individual lines between passes. The result is a file that goes
Statement semicolon newline
Statement semicolon newline
Stat newline
ement semicolon newline
Statement semicolon newline
Statement semicolon newline
So I need to parse the file to find newlines not preceded by a semicolon and get rid of them.
I'm afraid this is beyond my current comfort level with the stream editor but I am convinced it can be done. I considered a multiple pass approach of removing all newlines and then substituting all semicolons with semicolon+newline but that is not elegant.
Your help is greatly appreciated !
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2008 11:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2008 11:38 AM
06-16-2008 11:38 AM
Re: Need some sed magic
Ah yes, indeed a case of the right tool for the job. Quite an interesting logical operator :).
I have learned something today, thank you very much !
I have learned something today, thank you very much !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2008 09:04 PM
06-16-2008 09:04 PM
Re: Need some sed magic
>I'm afraid this is beyond my current comfort level with the stream editor
It would probably be move obvious using awk.
But here is a sed solution:
sed -e '
: recheck
/;$/!{ ;# no semicolon at the end
N
s/\n// ;# remove embedded newline
b recheck
}
' broken
It would probably be move obvious using awk.
But here is a sed solution:
sed -e '
: recheck
/;$/!{ ;# no semicolon at the end
N
s/\n// ;# remove embedded newline
b recheck
}
' broken
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP