Last active
May 3, 2017 07:18
-
-
Save mariuswilms/da5245c0e689b17b1162408d12e28279 to your computer and use it in GitHub Desktop.
Reset copyright year of each source file in Git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dir=$1 | |
old=$2 | |
files=$(ack -l "Copyright $old") | |
for f in $files; do | |
year=$(git log --follow -M -C --format=%ad --date=format:%Y $f | tail -1) | |
echo "$year : $f" | |
rpl -q "Copyright $old" "Copyright $year" $f | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rpl
does not add any trailing newline, but is an extra command to install. Alternatively useperl -i -pe "s#${2}#${3}#g"