Remove blank lines from the beginning of a file
July 2019
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
This site is an effort to share some of the base knowledge I have gathered through all this years working with Linux, FreeBSD, OpenBSD, Python or Zope, among others. So, take a look around and I hope you will find the contents useful.
Recent Entries
Recent Comments
Recent Trackbacks
OpenBSD (9 items)
BSD (0 items)
FreeBSD (19 items)
Linux (3 items)
Security (3 items)
Python (22 items)
Zope (13 items)
Daily (144 items)
e-shell (9 items)
Hacks (14 items)
PostgreSQL (3 items)
OSX (8 items)
Nintendo DS (0 items)
enlightenment (0 items)
Apache (3 items)
Nintendo Wii (1 items)
Django (24 items)
Music (12 items)
Plone (7 items)
Varnish (0 items)
Lugo (2 items)
Sendmail (0 items)
europython (7 items)
Cherokee (1 items)
self (1 items)
Nature (1 items)
Hiking (0 items)
uwsgi (0 items)
nginx (0 items)
cycling (10 items)
Networking (1 items)
DNS (0 items)

Syndicate this site (XML)

RSS/RDF 0.91

27 octubre

Remove blank lines from the beginning of a file

you can use sed, or you can use the BlankLineEraser! :D

This morning Marcos asked me for a solution to a common issue in a sysadmin/developer daily work. He needed a way to quickly/easily remove blank lines from the beginning of a file, if they exist (hehe, it doesn't work to assume the first lines are blank...).

After some time trying sed and its man page, and even searching through google, I found a quick sed one liner:

sed '/./,$!d' filename

And I quickly build a small shell script that uses it to parse a given file and create a parsed version of the file:

Perhaps some of you could find it useful... who knows... ;D

Posted by wu at 14:31 | Comments (1) | Trackbacks (0)
<< Each time you do not add a subject to an email... | Main | Un poco de humor nunca viene mal >>
Re: Remove blank lines from the beginning of a file

Thank You Brotha ! :D

Posted by: MarcosBL at octubre 28,2009 12:46
Re: Remove blank lines from the beginning of a file

np, glad to help! I've been thinking in a better version that checks for the $1 parameter to be a directory, and if it is a directory, do a recursive check inside all files within that directory... should be easy :D

Posted by: Wu at octubre 28,2009 12:51
Please send trackback to:
There are no trackbacks.
Post a comment