Skip to content

Instantly share code, notes, and snippets.

@dazz
Created January 22, 2014 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dazz/8557351 to your computer and use it in GitHub Desktop.
Save dazz/8557351 to your computer and use it in GitHub Desktop.
add license header to all files
#!/bin/bash
find . -name '*.php' -type f | while read files
do
sedtest=$(sed -n '/^/,/$/p' "${files}" | sed -n '/<?php/p')
if [ "${sedtest}" ]
then
echo ${files}
sed -e "s@<?php@<?php\n\/\*\*\n \* EasyBib Copyright 2008-2014\n \* Modifying, copying, of code contained herein that is not specifically authorized\n \* by Imagine Easy Solutions LLC ("Company") is strictly prohibited. Violators will\n \* be prosecuted.\n \*\n \* This restriction applies to proprietary code developed by EasyBib. Code from\n \* third-parties or open source projects may be subject to other licensing\n \* restrictions by their respective owners.\n \*\n \* Additional terms can be found at http://www.easybib.com/company/terms\n \*\/@g" "${files}" > "${files}".tmp
mv "${files}".tmp "${files}"
fi
done
@dazz
Copy link
Author

dazz commented Jan 30, 2014

you just need to

  • put this script in the directory and run it
  • it replaces <?php with <?php\n ... license

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