3 ms·
I wrote a util a bit like this when I realised there was no command for emptying a directory: https://github.com/adamserafini/emptydir https://github.com/adamse
by aserafini 6y ago
I wrote a util a bit like this when I realised there was no command for emptying a directory: https://github.com/adamserafini/emptydir https://github.com/adamserafini/emptydir
- jfreax 6y agoWhat the difference in just deleting the whole directory and recreating it with `mkdir`. Or just do an `rm -rf dir/*`?
- ggrrhh_ta 6y agoHidden directories, links within dir... (usually, you want a "nofollow" default for destructive operations)
- slavik81 6y agoWhile your code is very nicely factored, well-documented and quite readable, bash is not an easy language for this sort of utility. Any names containing spaces or starting with dashes require very careful handling. If you do stick with bash, I would recommend giving shellcheck a try. It won't catch everything, but I've learned a lot from running it on my code.