The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to delete files with certain ext? tonyvirk UNIX for Dummies Questions & Answers 4 12-09-2007 03:57 PM
How to delete files ?? preethgideon UNIX for Dummies Questions & Answers 5 10-29-2007 04:51 AM
how to delete log files castlerock Shell Programming and Scripting 2 03-29-2006 04:42 PM
when I try to run rm on multiple files I have problem to delete files with space umen UNIX for Dummies Questions & Answers 1 09-20-2005 04:20 AM
I can't delete some files DISTURBED UNIX for Dummies Questions & Answers 4 08-01-2002 12:15 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-23-2006
mephisto mephisto is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 2
Delete files with 0kb

Hi, i need to strip out a logfile dir, but only remove the files with 0kb . How would i go about doing this?

TIA
  #2 (permalink)  
Old 10-23-2006
napolayan napolayan is offline
Registered User
  
 

Join Date: Oct 2006
Location: Bangalore, India
Posts: 41
ls -l|while read line
do
awk '$5 != 0 {print $0}'
done>file1


$5 is the fifth field in output of ls - l which gives the no. of characters in the file. so i hv written all the files which dont hv zero characters (or bytes) to file1
  #3 (permalink)  
Old 10-23-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,800

Code:
find /path/to/logs -type f  -size 0 -exec rm -f {} \;

  #4 (permalink)  
Old 10-23-2006
mephisto mephisto is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 2
BIG thankyou.

thanks v much for your help i used

find . -size 0 -exec rm {} \;

which indeed worked perfectly.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0