Skip to content

Instantly share code, notes, and snippets.

@lnaia
Created July 8, 2016 09:50
Show Gist options
  • Save lnaia/bd3da112a552a9319ba89c37900c4c8b to your computer and use it in GitHub Desktop.
Save lnaia/bd3da112a552a9319ba89c37900c4c8b to your computer and use it in GitHub Desktop.
Create a report for all types of files within a given directory. Save full path to each file, and echo stat data to the screen.
#!/bin/bash
DIR=$1
EXTENSIONS=`find $DIR -type f | perl -ne 'print $1 if m/\.([^.\/]+)$/' | sort -fu`
for ftype in $EXTENSIONS; do
echo -n "Searching for $ftype ... "
find $DIR -type f -iname "*.$ftype" -fprint $ftype.log
echo found `wc $ftype.log -l | cut -d' ' -f 1` files
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment