Skip to content

Instantly share code, notes, and snippets.

@carlosmcevilly
Created February 6, 2014 02:04
Show Gist options
  • Save carlosmcevilly/8837171 to your computer and use it in GitHub Desktop.
Save carlosmcevilly/8837171 to your computer and use it in GitHub Desktop.
make hashes of the ls -lR output for each directory and its subdirectories (one level down) in a ~/work/ directory
#!/bin/bash
export index=~/work/indexes
mkdir -p $index
cd ~/work
for dir in `ls -d *`
do
if [[ -d "$dir" ]]; then
echo doing $dir
ls -lR $dir/ > $index/$dir.ls-lR.txt
cd $dir
for subdir in `ls -d *`
do
if [[ -d "$subdir" ]]; then
export hashed=`echo $subdir | shasum | cut -f1 -d' '`
ls -lR $subdir/ > $index/$dir-$hashed-ls-lR.txt
fi
done
cd ~/work/
fi
done
cd indexes
shasum -a 384 *ls-lR.txt > hashes.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment