- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: SED Delete multiple sets of 2 Lines in stacked...
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
10-14-2008 10:08 AM
10-14-2008 10:08 AM
SED Delete multiple sets of 2 Lines in stacked file
01 LINE (keep this header)
SOME LINE
SOME LINE
SOME LINE
99 LINE (delete this footer)
01 LINE (delete this header)
SOME LINE
SOME LINE
SOME LINE
SOME LINE
99 LINE (delete this footer)
01 LINE (delete this header)
SOME LINE
SOME LINE
99 LINE (delete this footer)
01 LINE (delete this header)
SOME LINE
99 LINE (keep this footer)
Results would have just 1 01 and 99 line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 10:19 AM
10-14-2008 10:19 AM
Re: SED Delete multiple sets of 2 Lines in stacked file
http://www.unix.com/shell-programming-scripting/24126-how-change-file-sed.html
You may need to take multiple passes on the file to do this.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 10:25 AM
10-14-2008 10:25 AM
Re: SED Delete multiple sets of 2 Lines in stacked file
Using your actual, posted sample:
# perl -ne 'print if eof;print unless /^99 LINE/../^01 LINE/' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 11:10 AM
10-14-2008 11:10 AM
Re: SED Delete multiple sets of 2 Lines in stacked file
cat file | awk '
/^99 LINE/ {
OLDLINE=$0;
if (!getline) {
print OLDLINE
exit
}
}
{ print $0 }
'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 10:08 PM
10-14-2008 10:08 PM
Re: SED Delete multiple sets of 2 Lines in stacked file
awk '
BEGIN { getline; print $0 }
/01 LINE/ { next }
/99 LINE/ { save=$0; next }
{
print $0
}
END { print save } ' file