Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find blank lines in a file

Status
Not open for further replies.

q4s72534

MIS
Aug 19, 2003
59
US
how do i find blank lines in a file?
 
To find the blank lines -

grep '^$' {File name}


If you are looking to strip the blank lines out you will need to use either awk or sed.


Steve
 
To remove empty lines :
sed '/^$/d' filename > newfilename
To remove line(s) with just a space :
sed '/^ /d' filename > newfilename


Dickie Bird (:)-)))
 
One regular expression for blank lines (not necessary empty):
Code:
/^[  ]*$/
    ^__ Tab char

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top