update_copyright.sh 719 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/awk -f
  2. # A simple awk script to update copyright lines
  3. # It can be used in a simple loop, e.g.:
  4. #
  5. # cd src
  6. # for i in $a; do
  7. # echo $i
  8. # ../update_copyright.sh $i >xx
  9. # rc=$?
  10. # if [ $rc == "0" ]; then
  11. # echo "$i contains no (c)."
  12. # else
  13. # mv xx $i
  14. # fi
  15. # done
  16. BEGIN {
  17. found_something=0;
  18. }
  19. /\(C\)/ {
  20. if(index($4,"-")>0)
  21. new_years=gensub("-.*$","-2015",1,$4);
  22. else
  23. new_years=$4"-2015";
  24. line = $0;
  25. sub($4,new_years,line);
  26. print line;
  27. found_something=1;
  28. next;
  29. }
  30. {
  31. print $0;
  32. }
  33. END {
  34. exit(found_something);
  35. }