The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell script for delete old files krishnarao Shell Programming and Scripting 4 01-13-2009 04:33 AM
Script to remove all empty files within the directory structure? cat123 Shell Programming and Scripting 5 06-05-2008 09:01 AM
How to delete files in UNIX using shell script theguy16 Shell Programming and Scripting 7 04-09-2008 04:40 AM
Delete an empty file from dir. Script40 Shell Programming and Scripting 2 04-02-2008 05:09 PM
Shell Script using Join, empty field help! tibbyuk UNIX for Dummies Questions & Answers 1 02-25-2008 12:33 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-11-2002
rpnuge rpnuge is offline
Registered User
  
 

Join Date: Jul 2002
Posts: 1
Talking how to delete empty files in a shell script

I'm trying to figure out a way to delete empty files in a directory. I have a cron that runs and creates a flat file every 15 mins. However, most times at night the flat file will be empty.

I'd like to run a script to delete empty files that end with *.dat

Any suggestions?

Rich
  #2 (permalink)  
Old 07-11-2002
RTM's Avatar
RTM RTM is offline Forum Advisor  
Hog Hunter
  
 

Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
find ./ -name "*.dat" -size 0 -exec rm {} \;

Read your man page before invoking this so you understand the implications - find goes through sub-directories by default and if you don't put the {} \; correctly, it will cause problems (could start deleting things you did not want to delete).
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 03:55 PM.


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