Created
December 4, 2022 20:01
-
-
Save rsa16/d3d22c2edac2f1088b6ed370f82afd80 to your computer and use it in GitHub Desktop.
Auto paste copyrights on every c++ and header file you got
This file contains hidden or 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 | |
| if [ -z "$1" ] | |
| then | |
| echo "You must supply your name as an argument." | |
| exit -1 | |
| fi | |
| copyright_text=" Copyright (c) $(date +"%Y"), $1\n All rights reserved.\n\n This source code is licensed under the BSD-style license found in the\n LICENSE file in the root directory of this source tree." | |
| for file in $(find .. -type f -name \*.cpp | grep -v external | grep -v build); do | |
| echo -e "/*\n$copyright_text\n*/" > copyright-file.txt; | |
| echo "" >> copyright-file.txt; | |
| cat $file >> copyright-file.txt; | |
| mv copyright-file.txt $file; | |
| done | |
| # headers too | |
| for file in $(find .. -type f -name \*.h | grep -v external | grep -v build); do | |
| echo -e "/*\n$copyright_text\n*/" > copyright-file.txt; | |
| echo "" >> copyright-file.txt; | |
| cat $file >> copyright-file.txt; | |
| mv copyright-file.txt $file; | |
| done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
grep -v externalis to filter it to make sure I'm not accidentally copy-righting my third-party libraries in my external folder, so you may get rid of it.