- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Sed problem....want to remove lines
Operating System - HP-UX
1753792
Members
7256
Online
108799
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
Discussions
Discussions
Forums
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
тАО03-14-2003 12:49 PM
тАО03-14-2003 12:49 PM
Sed problem....want to remove lines
I am using the following sed statement
sed -e :a -e 's/<[^>]*>//g;/
When it finds and instance, its leaving a blank space in its place.
Most of the time, this is something on one line. Is there a way I can make the sed statement delete the line after the character match is removed instead of leaving a blank line? I am trying to clean-up the formatting. Thanks
sed -e :a -e 's/<[^>]*>//g;/
When it finds and instance, its leaving a blank space in its place.
Most of the time, this is something on one line. Is there a way I can make the sed statement delete the line after the character match is removed instead of leaving a blank line? I am trying to clean-up the formatting. Thanks
- Tags:
- sed
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-15-2003 01:05 AM
тАО03-15-2003 01:05 AM
Re: Sed problem....want to remove lines
This will remove blank lines:
grep -v "^$" file1 > file2
cp file2 file1
grep -v "^$" file1 > file2
cp file2 file1
Support Fatherhood - Stop Family Law
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-15-2003 08:02 AM
тАО03-15-2003 08:02 AM
Re: Sed problem....want to remove lines
you can add a
-e '/^$/d'
which will delete all blank lines from the file.
or (not so easy from the command line):
/instance pattern/ {
s/this/that/
n
d}
this makes a substitution,
n writes your change to stdout and reads the next line into the pattern buffer, d deletes that line (whatever it is)
or
n
/^$/d} to just delete the next line if it blank.
-e '/^$/d'
which will delete all blank lines from the file.
or (not so easy from the command line):
/instance pattern/ {
s/this/that/
n
d}
this makes a substitution,
n writes your change to stdout and reads the next line into the pattern buffer, d deletes that line (whatever it is)
or
n
/^$/d} to just delete the next line if it blank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-15-2003 10:52 AM
тАО03-15-2003 10:52 AM
Re: Sed problem....want to remove lines
To get rid of the blank space JUST for this substitution without affecting the rest of the rest of the existing blank lines you can do this .. (a little modification to Curt's suggestion) ..
sed -e :a -e 's/<[^>]*>/=/g;/
Basically replace it with "=" and then delete that line later. That way you still retain the blank lines which are not part of this substitution. This may not be as elegant but it works.
sed -e :a -e 's/<[^>]*>/=/g;/
Basically replace it with "=" and then delete that line later. That way you still retain the blank lines which are not part of this substitution. This may not be as elegant but it works.
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP