Skip to content

Instantly share code, notes, and snippets.

@darrik
Created April 18, 2015 19:42
Show Gist options
  • Save darrik/5a0cd70c899d90c6df03 to your computer and use it in GitHub Desktop.
Save darrik/5a0cd70c899d90c6df03 to your computer and use it in GitHub Desktop.
Finding files on zfs that has copies=2 (or more)
#!/bin/bash
for file in $(/bin/ls *.jpg); do
size=$(/bin/ls -l $file | awk '{printf $5}')
dusize=$(du --block-size=1 $file | awk '{print $1}')
verify=$(echo $size*1.5/1 | bc)
if [ $dusize -gt $verify ]; then
dusize=$(printf "%'d" $dusize)
size=$(printf "%'d" $size)
echo "$file has copies>1 ($dusize > $size)"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment