Delete files with 0kb


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Delete files with 0kb
# 1  
Old 10-23-2006
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  
Old 10-23-2006
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  
Old 10-23-2006
Code:
find /path/to/logs -type f  -size 0 -exec rm -f {} \;

# 4  
Old 10-23-2006
BIG thankyou.

thanks v much for your help i used

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

which indeed worked perfectly.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

0kb file transferred in FTP process

We are transferring xml files to remote machine through cronjob @every 5 mins and then will move the files to the backup folder is source server. Sometimes the file is transferred as 0kb to destination server, whereas the file in the source backup folder is completely written. There is no error... (6 Replies)
Discussion started by: Bhavi
6 Replies

2. Shell Programming and Scripting

Script needed to delete to the list of files in a directory based on last created & delete them

Hi My directory structure is as below. dir1, dir2, dir3 I have the list of files to be deleted in the below path as below. /staging/retain_for_2years/Cleanup/log $ ls -lrt total 0 drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2 drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies

3. Shell Programming and Scripting

Delete all files if another files in the same directory has a matching occurrence of a specific word

he following are the files available in my directory RSK_123_20141113_031500.txt RSK_123_20141113_081500.txt RSK_126_20141113_041500.txt RSK_126_20141113_081800.txt RSK_128_20141113_091600.txt Here, "RSK" is file prefix and 123 is a code name and rest is just timestamp of the file when its... (7 Replies)
Discussion started by: kridhick
7 Replies

4. UNIX for Dummies Questions & Answers

Concatenate files and delete source files. Also have to add a comment.

- Concatenate files and delete source files. Also have to add a comment. - I need to concatenate 3 files which have the same characters in the beginning and have to remove those files and add a comment and the end. Example: cat REJ_FILE_ABC.txt REJ_FILE_XYZ.txt REJ_FILE_PQR.txt >... (0 Replies)
Discussion started by: eskay
0 Replies

5. Shell Programming and Scripting

Need help creating a script to FTP files to a server and then delete the files that were transfered.

I am trying to FTP files to a Windows server through my Linux machine. I have setup the file transfer with no problems but am having problem deleting those files from the Linux box. My current non-working solution is below. Any ideas, anyone?? :wall: Please be gentle, I'm fairly new to this... (4 Replies)
Discussion started by: jmalfhs
4 Replies

6. UNIX for Dummies Questions & Answers

File SIZE 0KB help

Hi There, I need a script which shud basically check the size of the file..if its is 0kb send email to a list of people and if is > 0KB, send an email to someother list... Please help (1 Reply)
Discussion started by: saggiboy10
1 Replies

7. Shell Programming and Scripting

Delete all files if another files in the same directory has a matching occurence of a specific word

Hello, I have several files in a specific directory. A specific string in one file can occur in another files. If this string is in other files. Then all the files in which this string occured should be deleted and only 1 file should remain with the string. Example. file1 ShortName "Blue... (2 Replies)
Discussion started by: premier_de
2 Replies

8. Shell Programming and Scripting

Shell script to FTP if file size is 0KB

Hi all, I was a UNIX shell script that will check for the file size of each file and it should be re directed to a text file say filesize.txt And if there are more than 10 0KB files then FTP should not happend and whenever there are less than 10 0KB files it should FTP the files. Kindly help me... (1 Reply)
Discussion started by: Codesearcher
1 Replies

9. Solaris

0KB printing files

Hi, I am dealing with strange problem... whenever we use our software to trigger some printing files, along with that it generates lot of zero KB printing files, in our code base we generate a printing file only if its size is >0. So I suspect it could be something to do with printing level... (2 Replies)
Discussion started by: vivek.gkp
2 Replies

10. Shell Programming and Scripting

How to separate 0kb files from the rest!!!

Hi All, Can you please tell me how to identify a 0kb file from a list a files and redirect only those files to a .txt file. ls -l shows me all the 0kb files...but how to redirect only those files.. Thanks for ur help, Kumar (3 Replies)
Discussion started by: kumarsaravana_s
3 Replies
Login or Register to Ask a Question