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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help please - grep for null lines

Status
Not open for further replies.

Advocate

IS-IT--Management
Oct 18, 2000
135
GB
good morning,

could anyone tell me how to grep a file for null lines please ? returning line numbers ...

tried following info in man grep but does not seem to work
man refers to
grep -e \n\n notes.txt
but i must have syntax wrong

tried
grep -n -v J notes.txt
but not all lines have J in text

thank you in advance
Best of Irish Luck, David.
djwilkes@hotmail.com
 
grep -n "^$" filename should return the null lines

Dave
 
thanks dave but that does not work

it does not return any lines - i know there are 10 blank lines in file of 90k lines

i am using aix csh

any more ideas please ?
Best of Irish Luck, David.
djwilkes@hotmail.com
 
sorry ygor but still no data returned
Best of Irish Luck, David.

 
I think those 'blank' lines must have some unprintable characters.
 
How 'bout sed to remove 'em:
sed '/[a-zA-Z0-9 ]/!d' notes.txt > newfile
(the large space is a tab and a space)
Any line without alphanumerics, space & tab will be deleted
HTH Dickie Bird (:)-)))
 
If they are null lines they will show up with the grep I suggested. I just tested it out by creating a file with 13 null lines and it listed them perfectly.

I would suggest checking exactly what the lines contain since they would appear not to be null; perhaps they have a space character in them for example

Dave
 
i suspect that they have an invisible newline character in them ...
Best of Irish Luck, David.

 
Try

grep -n &quot;^[ <tab>]*$&quot; notes.txt

where the characters in the square brackets are a space followed by a tab. CaKiwi

&quot;I love mankind, it's people I can't stand&quot; - Linus Van Pelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top