diff --git a/misc-scripts/annual_copyright_updater.sh b/misc-scripts/annual_copyright_updater.sh new file mode 100755 index 0000000000000000000000000000000000000000..21b8ddd7a763864c43dada68f126e16a0579ce12 --- /dev/null +++ b/misc-scripts/annual_copyright_updater.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +function confirm() +{ + echo -n "$@ " + read -e answer + for response in y Y yes YES Yes Sure sure SURE OK ok Ok + do + if [ "_$answer" == "_$response" ] + then + return 0 + fi + done + + return 1 +} + +year=$(date "+%Y") +last_year=$(($year - 1)) + +search="Copyright (c) 1999-${last_year}" +replacement="Copyright (c) 1999-${year}" + +confirm "About to scan $(pwd) for files to replace '$search' with '$replacement'. Ok?" + +for file in $(grep -R --files-with-matches "$search" .); do + echo "Replacing date in $file" + sed -i "s/$search/$replacement/g" $file +done +