Skip to content

Instantly share code, notes, and snippets.

@rsa16
Created December 4, 2022 20:01
Show Gist options
  • Select an option

  • Save rsa16/d3d22c2edac2f1088b6ed370f82afd80 to your computer and use it in GitHub Desktop.

Select an option

Save rsa16/d3d22c2edac2f1088b6ed370f82afd80 to your computer and use it in GitHub Desktop.
Auto paste copyrights on every c++ and header file you got
#!/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
@rsa16
Copy link
Author

rsa16 commented Dec 4, 2022

The grep -v external is 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment