Find the oldest line in your repo
This is how all my projects go. I get a wild hare and then figure out how I can make a shell script to do it. Thanks to some help from people online, I was able to make a script that listed out the oldest lines in a git repo. Kind of fun to see what legacy stuff is still around.
Stack Overflow question that was helpful
`git` gist I used as a starting point
#!/bin/bash
# the `grep` call is to only match non-binary files
for file in $(find $1 -type f -not -path './node_modules/*' -not -path './.git/*' -exec grep -I -q . {} \; -print); do
# this is to only do a blame on files that are tracked
git ls-files --error-unmatch "$file" &>/dev/null
if [[ $? == 0 ]]; then
git blame --date=format:%Y%m%d -f $file
fi
# I made the `match` call only search for years that start with `20`, so needs modification if commits precede 2000
done | awk $'{ match($0, /20[0-2][0-9]{5}/); print substr($0, RSTART, RLENGTH) "\t" $0 }' | sort -r | tail