Skip to content

Instantly share code, notes, and snippets.

@akx
Created July 25, 2016 06:45
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 akx/1c99d5d16f7a072b1c505ba63b28e0a2 to your computer and use it in GitHub Desktop.
Save akx/1c99d5d16f7a072b1c505ba63b28e0a2 to your computer and use it in GitHub Desktop.
git-lastmod.sh: print the last commit dates of currently existing files in the current repository
#!/bin/bash
# print the last commit dates of currently existing files in the current repository
(
git ls-files | sed 's/^/+ /'
git log --format=format:"~ %aI" --name-only .
) | gawk '
/^~/ {date=$2;}
/^+/ {extant[$2] = 1;}
/^[^~+]/ {dates[$1] = date;}
END { for (file in dates) if(extant[file]) print(dates[file], file); }
' | sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment