Skip to content

Instantly share code, notes, and snippets.

@caarlos0
Last active December 1, 2015 17:28
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 caarlos0/4501ae18631597abb9a5 to your computer and use it in GitHub Desktop.
Save caarlos0/4501ae18631597abb9a5 to your computer and use it in GitHub Desktop.
#!/bin/bash
# name: old-files.sh
# author: Carlos Alexandro Becker (caarlos0@gmail.com)
#
# List the files not changed in a git repo in the last X time.
#
# Usage:
# ./old-files.sh 1 year
#
set -eo pipefail
dir="$(mktemp -d)"
git log \
--pretty="format:" \
--since="$* ago" \
--name-only | sort | uniq > "$dir/recently_changed"
git log \
--pretty="format:" \
--name-only | sort | uniq > "$dir/all"
for file in $(diff "$dir/recently_changed" "$dir/all" | cut -f2 -d' '); do
[ -f "$file" ] && echo $file
done | sort | uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment