Skip to content

Instantly share code, notes, and snippets.

@tknerr
Created June 14, 2016 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tknerr/b9966738a139d7a05f3407f4351c8105 to your computer and use it in GitHub Desktop.
Save tknerr/b9966738a139d7a05f3407f4351c8105 to your computer and use it in GitHub Desktop.
show the total count and list the first 10 files per day, archive all of them
# show the total count and list the first 10 files per day
for i in `seq 1 100`; do files=$(find . -daystart -mtime $i); num=$(echo $files | wc -w); date=$(date -d "-$i day" +%Y-%m-%d); if [ $num -gt 0 ]; then echo "$num files found for $date"; echo $files | tr ' ' '\n' | xargs ls -l | head -n 10; fi; done
# also archive...
for i in `seq 1 100`; do files=$(find /var/log/ccu/noise-test -daystart -mtime $i -name "TM-Noise*.csv.*.gz"); num=$(echo $files | wc -w); date=$(date -d "-$i day" +%Y-%m-%d); if [ $num -gt 0 ]; then echo "$num files found for $date"; echo $files | tr ' ' '\n' | xargs ls -l | head -n 10; tar -czf /tmp/TM-NoiseTest-$date.tgz $files; fi; done
# long
for i in `seq 1 100`; do
files=$(find /var/log/ccu/noise-test -daystart -mtime $i -name "TM-Noise*.csv.*.gz");
num=$(echo $files | wc -w);
date=$(date -d "-$i day" +%Y-%m-%d);
if [ $num -gt 0 ]; then
echo "$num files found for $date";
echo $files | tr ' ' '\n' | xargs ls -l | head -n 10;
tar -czf /tmp/TM-NoiseTest-$date.tgz $files;
fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment