Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

copyright_year.sh 1.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  1. #!/usr/bin/env bash
  2. #
  3. # Script to update copyright year of all GMT files:
  4. #
  5. # bash admin/copyright_year.sh
  6. #
  7. lastyear=2019
  8. newyear=2020
  9. if [ ! -d cmake ]; then
  10. echo "Must be run from top-level gmt directory"
  11. exit 1
  12. fi
  13. # Set temporary directory
  14. TMPDIR=${TMPDIR:-/tmp}
  15. # 1. Find all files with "Copyright"
  16. find -E . \
  17. -regex '.*\.(md|c|h|in|rst|bash|csh|sh|bat|m|cmake|txt|TXT)' \
  18. ! -path "./share/spotter/*" \
  19. -exec grep -H Copyright {} + | \
  20. grep -v ${newyear} | \
  21. awk -F: '{print $1}' > ${TMPDIR}/$$.tmp.lis
  22. # 2. Add extra files not found by 'find'
  23. cat >> ${TMPDIR}/$$.tmp.lis << EOF
  24. ./src/gmtswitch
  25. ./src/grd2sph.c.template
  26. ./src/img/img2google
  27. ./share/tools/ncdeflate
  28. EOF
  29. # 3. Update the files
  30. while read f; do
  31. sed -E -i.bak "s/Copyright \(c\) ([0-9]+)-${lastyear}/Copyright \(c\) \1-${newyear}/" $f
  32. rm -f $f.bak
  33. done < ${TMPDIR}/$$.tmp.lis
  34. # 4. Update GMT_VERSION_YEAR in cmake/ConfigDefault.cmake
  35. sed -i.bak "s/set (GMT_VERSION_YEAR \"${lastyear}\")/set (GMT_VERSION_YEAR \"${newyear}\")/" cmake/ConfigDefault.cmake
  36. rm -f cmake/ConfigDefault.cmake.bak
  37. # 5. Clean up
  38. rm -f ${TMPDIR}/$$.tmp.lis
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...