Created
November 3, 2023 10:53
-
-
Save fenying/cfe74387f0387ed7a9a4fb1af680e6a0 to your computer and use it in GitHub Desktop.
Add Apache2 Copyright info to files
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
#!/usr/bin/env bash | |
if [[ -z "$2" ]]; then | |
echo './add-apache2-copyright.sh <path> <ext>'; | |
exit; | |
fi | |
for i in $(find $1 -type f -name "*.$2") | |
do | |
HAS_CR_COMMENT=$(cat $i | grep 'www.apache.org') | |
if [[ -z "$HAS_CR_COMMENT" ]]; then | |
cat > tmp-file << EOL | |
/** | |
* Copyright 2023 Angus.Fenying <[email protected]> | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* https://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
EOL | |
cat $i >> tmp-file | |
cat tmp-file > $i | |
fi | |
done | |
rm -f tmp-file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment