The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Delete an empty file from dir. Script40 Shell Programming and Scripting 2 04-02-2008 02:09 PM
display no of empty lines atticus Shell Programming and Scripting 5 03-22-2006 11:35 AM
delete multiple empty lines whatisthis Shell Programming and Scripting 3 11-09-2005 01:42 PM
cat and empty lines Nicol Shell Programming and Scripting 4 11-13-2003 05:19 AM
how to delete empty files in a shell script rpnuge UNIX for Advanced & Expert Users 1 07-11-2002 01:56 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-30-2008
Registered User
 

Join Date: Apr 2008
Posts: 18
How to delete empty lines

abc#
abc#this is a test
abc#this is a test to delete
abc#
xyz#
xyz#this is a test two
xyz#


In the above example '#' is common. How to do delete the emply lines. In specific to observe the output as:

abc#this is a test
abc#this is a test to delete
xyz#this is a test two
.
.
.
.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-30-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,661
Code:
awk -F# '$(NF)>1' file
Regards
Reply With Quote
  #3 (permalink)  
Old 04-30-2008
Registered User
 

Join Date: Apr 2008
Posts: 18
Cool It works.
Thanks Frank.
Reply With Quote
  #4 (permalink)  
Old 04-30-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,661
Or with grep:

Code:
grep '#.' < file
Regards

Last edited by Franklin52; 04-30-2008 at 07:18 AM. Reason: edit quotes
Reply With Quote
  #5 (permalink)  
Old 04-30-2008
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,470
one more

Code:
grep -v "#$" filename
Reply With Quote
  #6 (permalink)  
Old 04-30-2008
Registered User
 

Join Date: Apr 2008
Posts: 18
Thanks Folks. Will try all the options.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0