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

Deleting spaces between two records in a file

Status
Not open for further replies.

hello99hello

Programmer
Jul 29, 2004
50
CA
I have these file containing the folowwing records:

Lai Phat 37739 jdsk876

Dema Koheen 346747 jsdfjkla990

Lar Solomon 484848 jfsaj898

When I do wc -l file1, it reports 5 records. Thereby counting the line-space before and after "Dema Koheen 346747 jsdfjkla990" as record lines.

I was wondering if there is a script I can run to eliminate the line space before and after "Dema Koheen 346747 jsdfjkla990". Just so my file1 could look like:

Lai Phat 37739 jdsk876
Dema Koheen 346747 jsdfjkla990
Lar Solomon 484848 jfsaj898

and my wc -l could report 3 records.

Thanks for your help.
 
Thanks...your solution is counting the non-space records. However, I am interested in deleting the space records.
 

awk 'NF' infile > outfile
wc -l outfile

CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top