Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Remove zero bytes files in folder

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-18-2007   -   Original Discussion by cedrichiu
cedrichiu's Unix or Linux Image
cedrichiu cedrichiu is offline
Registered User
 
Join Date: Mar 2007
Last Activity: 23 March 2008, 5:42 AM EDT
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Remove zero bytes files in folder

Hi,

Please shed some light on how to quickly remove all the zero bytes in which there are some mixtures of more than zero bytes in it.

For eg:
> ls -lrt

-rw-r--r-- 1 ab noen 0 Jul 27 15:47 supplier_mp.unl
-rw-rw-r-- 1 ab noen 507 Aug 5 14:13 glance.err
-rw-r--r-- 1 ab noen 0 Aug 15 09:46 aaa.txt
-rw-r--r-- 1 ab noen 662 Aug 16 15:15 role999
-rw-r--r-- 1 ab noen 0 Aug 28 12:18 test
-rw-r--r-- 1 ab noen 566 Sep 11 08:48 cmd_srv_11092007
-rw-r--r-- 1 ab noen 0 Oct 3 16:15 run_new.log
-rw-r--r-- 1 ab noen 611 Oct 4 10:32 Query.in
-rw-r--r-- 1 ab noen 0 Oct 4 10:32 Response.log
-rw-r--r-- 1 ab noen 949 Oct 4 10:32 Request.log
-rw-r--r-- 1 ab noen 864 Oct 4 10:32 Summary.log
-rw-r--r-- 1 ab noen 424 Oct 9 01:57 skill.sh


Help..
Sponsored Links
    #2  
Old Unix and Linux 10-18-2007   -   Original Discussion by cedrichiu
porter's Unix or Linux Image
porter porter is offline Forum Advisor  
Registered User
 
Join Date: Jan 2007
Last Activity: 8 January 2008, 6:50 PM EST
Posts: 2,965
Thanks: 0
Thanked 5 Times in 5 Posts
To find zero length files use



Code:
find . -type f -size 0

so test with



Code:
find . -type f -size 0 | xargs ls -ld

if happy remove with



Code:
find . -type f -size 0 | xargs rm

The Following User Says Thank You to porter For This Useful Post:
asnatlas (01-31-2013)
Sponsored Links
    #3  
Old Unix and Linux 09-28-2008   -   Original Discussion by cedrichiu
./hari.sh's Unix or Linux Image
./hari.sh ./hari.sh is offline
Registered User
 
Join Date: Jul 2007
Last Activity: 27 August 2017, 12:27 PM EDT
Location: NY
Posts: 97
Thanks: 6
Thanked 4 Times in 4 Posts
remove 0 byte

Alternatively



Code:
find /home/hari -type f -size 0 -exec rm {} \;

The Following User Says Thank You to ./hari.sh For This Useful Post:
asnatlas (01-31-2013)
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Copying 1024 bytes data in 3-bytes chunk royalibrahim Programming 3 04-13-2011 03:32 PM
recursively remove javascript from all folder index files lsalsich Shell Programming and Scripting 2 02-07-2010 05:18 PM
remove all duplicate lines from all files in one folder lowmaster Shell Programming and Scripting 8 05-30-2009 08:45 AM
Files with zero bytes preethgideon UNIX for Dummies Questions & Answers 1 04-24-2009 06:22 PM
Remove first N bytes and last N bytes from a binary file on AIX. naveendronavall Shell Programming and Scripting 1 05-24-2008 12:06 PM



All times are GMT -4. The time now is 04:30 AM.