0

How can i loop through a directory (and subdirectories) and delete every .log file? I want to use a bash script to clean my Minecraft server directory.

In Windows (batch) i use this line to loop: for /r %%i in (*.log) do del /F %%i

Vico
  • 298

1 Answers1

1

To print all *.log files recursively using the current directory as start directory (just to make sure these are the right files), use:

find . -name "*.log" -type f

And to delete them, use:

find . -name "*.log" -type f -exec rm {} +
Freddy
  • 1,495