From d9ab133a8507e59d171ce8d43d642083883108e5 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Fri, 8 Jul 2016 14:08:20 +0100 Subject: [PATCH] Script for finding files with a given type --- files-with-type | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 files-with-type diff --git a/files-with-type b/files-with-type new file mode 100755 index 000000000..d969f4405 --- /dev/null +++ b/files-with-type @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# +# Find all files with a given MIME type. +# +# e.g. +# $ files-with-type text/x-shellscript k8s infra +# +# Assumes `find`, `xargs`, and `file` are all installed. + +mime_type=$1 +shift + +find "$@" -print0 -type f |xargs -0 file --mime-type | grep "${mime_type}" | sed -e 's/:.*$//'