👤
Home Man
Search
Today's Posts
Register

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

👤 Login to reply

 
Thread Tools Search this Thread
# 1  
Old 10-18-2007
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..
# 2  
Old 10-18-2007
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)
# 3  
Old 09-28-2008
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)
👤 Login to reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Divide an EBCDIC files into multiple files based on value at 45-46 bytes okkadu Shell Programming and Scripting 3 03-04-2013 04:14 PM
Shell script - entered input(1-40 bytes) needs to be converted exactly 40 bytes shravan.300 Shell Programming and Scripting 3 01-22-2013 01:48 AM
X bytes of 0, Y bytes of random data, Z bytes of 5, T bytes of 1. ?? razolo13 UNIX for Dummies Questions & Answers 1 12-02-2012 04:20 PM
Copying 1024 bytes data in 3-bytes chunk royalibrahim Programming 3 04-13-2011 02:32 PM
recursively remove javascript from all folder index files lsalsich Shell Programming and Scripting 2 02-07-2010 04:18 PM
need to pick out files which are not of zero bytes viv1 Shell Programming and Scripting 2 08-19-2009 03:54 PM
remove all duplicate lines from all files in one folder lowmaster Shell Programming and Scripting 8 05-30-2009 07:45 AM
Files with zero bytes preethgideon UNIX for Dummies Questions & Answers 1 04-24-2009 05: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 11:06 AM
retrieving files which has more than 0 bytes sri2005 UNIX for Dummies Questions & Answers 4 04-29-2008 10:22 AM


All times are GMT -4. The time now is 09:14 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?