Recursively Delete Files by Extension

Distributed Systems with Node.js, O'Reilly 2020, has been published!

Run this command to recursively delete files based on the provided extension (e.g. log):

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

You can remove everything after -exec (inclusive) to print the matched files to the screen (as a test run). You can change the . to be whatever directory you want to start in.

Tags: #linux #bash
Thomas Hunter II Avatar

Thomas has contributed to dozens of enterprise Node.js services and has worked for a company dedicated to securing Node.js. He has spoken at several conferences on Node.js and JavaScript, is an O'Reilly published author, and is an organizer of NodeSchool SF.