Skip to content

Instantly share code, notes, and snippets.

@cphyc
Last active May 31, 2017 15:35
Show Gist options
  • Save cphyc/c60090f3e9ab6125f0eb1edbf31bb15f to your computer and use it in GitHub Desktop.
Save cphyc/c60090f3e9ab6125f0eb1edbf31bb15f to your computer and use it in GitHub Desktop.
Follow the number of files created
#!/usr/bash
# To use:
# watch_count PATTERN [ARGS...]
# It will match the PATTERN and pass any remaining args to tqdm (that
# you need btw)
function watch_count {
pattern=$1
shift
curr=0
while true; do
sleep 2
prev=$curr
curr=$(ls $pattern | wc -l)
diff=$((curr-prev))
if [ ! "$diff" -eq "0" ]; then
for i in $(seq $prev $curr); do
echo $i
done
fi
done | tqdm $@ > /dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment