Quick Tip to Clean Up Rails Logs

Every few months I use this command to empty each and every one of my test.log and development.log files in the src folder of my laptop:

find ~/src \
  -maxdepth 6 \
  -type f \
  -mindepth 1 \
  \( -name "test.log" -or -name "development.log" \) \
  -exec truncate -s 0 {} \;

It works by…

  1. Finding files that match the name
  2. Using the truncate command to reduce the size of the file to 0 bytes

Instead of typing it out each time, I’ve created a quick alias in my .bash_profile when my shell loads:

alias truncate_devlogs='find . -maxdepth 6 -type f -mindepth 1 \( -name "test.log" -or -name "development.log" \) -exec truncate -s 0 {} \;'

Then when I remember to do so, or I wrap up work on a project, a quick truncate_devlogs recoups disk space and makes me feel better.


Now read this

Typo Forgiveness in Git & Bash

I’m often moving pretty quickly when it comes time to commit work to Git. I have a bit of a workflow down, and I type the same few shortcuts frequently: $ git st (expands to status) $ git ks (expands to difftool, which opens... Continue →