Monday, December 9, 2019

How to Delete million of file in certain directory

How to Delete million of file in certain directory.

When administrator get request for deleting files which having large number, then simple "rm" command will not work. Solution to this problem is following command.

find . -type f -name "*.bak" -exec rm -i {} \;

Above command will find files with ".bak" extension and will delete them. IF administrator want to specify any specific path then he also specify that path like below.

find /backup -type f -name "*.bak" -exec rm -i {} \;