List all files in a subdirectory, with the SHA1 sums
Useful for diffing two sets of filesystems, just to see where the changes are (and maybe catch a file that was accidentally copied in)
Symbolic links and other non-regular files are ignored. If they’ve changed, there is no alarm on these.
The script (the path to the directory to be scanned is given as an argument):
#!/bin/bash [ -d "$1" ] || exit 1; cd $1 || exit 1; find . | while read i; do if [ -f "$i" ] && [ ! -h "$i" ]; then sha1sum "$i"; else echo "---------------------------------------- $i"; fi done
To sort the output:
$ sort -k 1.41 list-of-files.txt > sorted.txt
The -k parameter causes sort to work from character 41 and on. Otherwise it would sort according to the SHA1 sums.