Deleting many defect or stats files in /etc/wily/cem/tim/data/out.

Document ID : KB000017470
Last Modified Date : 14/02/2018
Show Technical Document Details

Description:

Many files may end up on the TIM due to defect storms or an unresponsive TIM Collector. In UNIX, running a ls or rm command may not work due to file expansion limits. Here are some alternatives.

Solution:

Using shell scripts and UNIX commands, there are many ways to do this. Some of these are listed below:


find . | xargs -n 50 rm -f        --This deletes 50 files at a time
 
find . -name \*.xml | xargs -n 50 rm -f -- delete 50 files at a time ending in xml
 
Example with bash: 
    for f in ( `ls`)
    do 
        rm -f $f
    done 

There are many links on this topic including:

http://unix.stackexchange.com/questions/96935/faster-way-to-delete-large-number-of-files