Comments on: How to Delete Large Directory with Thousands of Files in Linux https://www.tecmint.com/delete-large-directory-linux/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Thu, 13 Jul 2023 16:32:59 +0000 hourly 1 By: Kingneutron https://www.tecmint.com/delete-large-directory-linux/comment-page-1/#comment-2012980 Thu, 11 May 2023 14:10:13 +0000 https://www.tecmint.com/?p=51010#comment-2012980 If it took *84 minutes* to touch 500k 0-byte files, you’re doing something wrong.

On a 2011 core-i5 iMac with OSX High Sierra 10.13 running against a Firewire-800 spinning disk with APFS filesystem:

$ time echo {1..100000} |xargs -P 2 -n 1 touch

# Parallel process 2x / time

Begin:
Thu May 11 09:01:03 CDT 2023
real 1m47.971s

user 1m11.711s
sys 1m44.261s
Thu May 11 09:02:51 CDT 2023
End

xargs ~30% CPU,
Terminal ~20% cpu – and you can also preface the create command with ‘nice‘.

As for deleting a directory with thousands of files, I’d argue the *safest* way to do so would be to use Midnight Commander. Navigate to the directory, hit F8, and it asks for confirmation, no unexpected results.

]]>
By: Ravi Saive https://www.tecmint.com/delete-large-directory-linux/comment-page-1/#comment-2011942 Tue, 09 May 2023 03:47:08 +0000 https://www.tecmint.com/?p=51010#comment-2011942 In reply to Andreas Dorfer.

@Andreas,

Could you share one example, of how the find/exec rm method is a valid solution for this? It would be a great help for all Linux users…

]]>
By: Andreas Dorfer https://www.tecmint.com/delete-large-directory-linux/comment-page-1/#comment-2011709 Mon, 08 May 2023 18:37:46 +0000 https://www.tecmint.com/?p=51010#comment-2011709 This will not work on directories with a large number of files, where the shell (like bash) runs out of memory. There the find/exec rm method is a valid solution.

]]>
By: Arulkumar.g https://www.tecmint.com/delete-large-directory-linux/comment-page-1/#comment-2011642 Mon, 08 May 2023 16:14:39 +0000 https://www.tecmint.com/?p=51010#comment-2011642 Really very good article for deleting lakhs of files in a directory in Linux.

]]>