in Servers, Web Development

Removing large amount of files (argument list too long)

3 useful commands when you have a large amount of files to delete in case you’ve reached the inode limit or just want to remove them.

view inode usage

df -i

how many files?

ls -U1 | wc -l

Remove a folder containing these files

rm -fr folder/* or pattern like rm -fr folder/sess_*

If it’s really so large you can’t remove it with the above command a quicker way is to use find, (all files over 80 days old)

find /really/large/folder -name 'file_pattern_*' -type f -mtime +80 -exec rm {} \;

Or even quicker is to use rsync to empty the directory.

rsync -a --delete empty_dir/ yourdirectory/

Write a Comment