- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Getting rid of blank line
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
04-17-2009 06:34 AM
04-17-2009 06:34 AM
Getting rid of blank line
sp02 97216 Mbytes allocated to /dev/vgDEVsap across 7 PVs. PE size is 16 Mbyes, total of 6076 PE with 723 free
sp02 97216 Mbytes allocated to /dev/vgDEVsap across 7 PVs. PE size is 16 Mbyes, total of 6076 PE with 723 free
sp02 236096 Mbytes allocated to /dev/vgDEVdata across 17 PVs. PE size is 16
bytes, total of 14756 PE with 0 free
Now, i am getting this blank line after each entry that i want to get rid of.. Let me know what you think.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2009 06:38 AM
04-17-2009 06:38 AM
Re: Getting rid of blank line
One way:
# perl -pe 's/^\s*$//' file
...and if you want to update in place :
# perl -pi.old -e 's/^\s*$//' file
...which will create a backup of the input file as 'file.old'. This technique eliminates have to redirect to a temporary file and then overwrite your original file with the temporary one.
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2009 06:40 AM
04-17-2009 06:40 AM
Re: Getting rid of blank line
sed '/^$/d'
Pete
Pete
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2009 07:53 AM
04-17-2009 07:53 AM
Re: Getting rid of blank line
You can easily get rid out of this using simple grep.
#grep -v ^$ filename > newfilename
Hope this helps.
Ganesh.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2009 09:08 AM
04-17-2009 09:08 AM
Re: Getting rid of blank line
Unfortunately, using the regular expresssion (RE):
/^$/
...only rids the file of lines that consist solely of a newline. That is, any leading spaces and/or tabs will cause the RE _not_ to match.
If you don't wish to use Perl (where '\s' means whitespace (spaces, tabs), then you probably want:
# sed -e '/^[ ]*$/d' file
...where the character class in square brackets consists of a space _and_ a TAB character. Some 'sed' variants will allow:
\t
...to represent a TAB and you could be clearer by writing:
# sed -d '/^[ \t]*$/d' file
HP-UX doesn't understand this later notation.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2009 10:08 AM
04-17-2009 10:08 AM
Re: Getting rid of blank line
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2009 07:02 PM
04-17-2009 07:02 PM
Re: Getting rid of blank line
awk NF /your/file
or
awk NF /your/oldfile > /your/newfile
It will remove any line that is null or contains nothing bu blanks or tabs. But as mentioned, you might want to fix the code that is outputting the extra line.
Bill Hassell, sysadmin
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2009 08:49 PM
04-17-2009 08:49 PM
Re: Getting rid of blank line
You can simply use a character class:
grep -v '^[[:space:]]*$'
http://docs.hp.com/en/B2355-60130/regexp.5.html#d0e1178990
- Tags:
- regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2009 05:44 AM
04-18-2009 05:44 AM
Re: Getting rid of blank line
Where I used the term "character class" for the bracketed space+TAB character, I should properly have said "bracket expression".
Regards!
...JRF...