Last active
August 29, 2015 13:56
-
-
Save dportabella/9025210 to your computer and use it in GitHub Desktop.
command line tool to list all files, with properties and checksum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# use this script as follows: find . -mount -exec dstat {} \; | |
# this produces a list as follows: | |
# Regular File -rw-r--r-- david staff 2013-11-09 01:33:24 2013-11-09 01:33:24 14787 c3a7afd9e3cf89543352ee58e26cfb10 Invoice_41010102336895558_6601081486112013.pdf pdf ./accounting/files/Invoice_41010102336895557_6601081486112013.pdf | |
# Regular File -rw-r--r-- david staff 2013-09-01 00:41:05 2013-09-01 00:41:05 13636 55b47d2a41d5d6a072439ef2dabacac4 Invoice_41010102336895558_6601108809092013.pdf pdf ./accounting/files/Invoice_41010102336895557_6601108809092013.pdf | |
# ... | |
# see http://linux.die.net/man/1/stat for more stat options | |
if [ -z "$1" ] ; then | |
echo "dstat <file>" | |
exit 1 | |
fi | |
HASH=" " | |
if [ -f "$1" ] ; then | |
HASH=`md5 -q "$1"` | |
fi | |
FILENAME=$(basename "$1") | |
EXT="${FILENAME##*.}" | |
FILENAME_ESCAPED=$(echo $FILENAME | sed -e "s/%/%%/g") | |
EXT_ESCAPED=$(echo $EXT | sed -e "s/%/%%/g") | |
stat -t "%F %T" -f "%HT%t%Sp%t%Su%t%Sg%t%Sm%t%SB%t%14z%t$HASH%t$FILENAME_ESCAPED%t%SY%t$EXT_ESCAPED%t%N" "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment