The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to delete empty lines Aejaz UNIX for Advanced & Expert Users 5 04-30-2008 07:27 AM
File is not empty? lesstjm Shell Programming and Scripting 7 07-12-2007 07:21 AM
empty file in hp-ux Mizi UNIX for Advanced & Expert Users 2 08-09-2006 03:29 AM
delete multiple empty lines whatisthis Shell Programming and Scripting 3 11-09-2005 01:42 PM
how to delete empty files in a shell script rpnuge UNIX for Advanced & Expert Users 1 07-11-2002 01:56 PM

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

Join Date: Apr 2008
Posts: 2
Stumble this Post!
Delete an empty file from dir.

Hi,

I have an dir which has 50K file, some of them are empty. I want to delete the empty file from the dir. I am planning to use the following command.

ls -l | grep " 0 " | awk '{print $9}'

I can copy this to an file and then how do I use this file to delete the empty files.... Any help will be appreciated.

Thanks.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-02-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,961
Stumble this Post!
You can do something like this with find:

Code:
find . -size 0 -exec rm -f {} \;
To be shure you get the correct files you can ls those files first with:

Code:
find . -size 0 -exec ls -l {} \;
Regards
Reply With Quote
  #3 (permalink)  
Old 04-02-2008
Registered User
 

Join Date: Apr 2008
Posts: 2
Stumble this Post!
Thanks it worked.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:55 PM.


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