linuxfindrm

remove files that are in find result


I want to remove all files that have ".json" extension. so I run

find . -name "*.json"

this will result in some files

x.json
y.json
z.json

then I do rm for each file, but this is a very tedious task when you have many files.

is there any way to mix rm with find result


Solution

  • If using GNU find, it's dead simple:

    find directory/ -name "*.json" -delete