Last active
December 24, 2015 07:49
-
-
Save kalenjordan/6766591 to your computer and use it in GitHub Desktop.
Change copyright from 2013 to 2012
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
# I'm certain there's a much more elegant way to do this, but I'm | |
# not too handy with bash script. | |
# Change all the instances of 2013 copyright to 2012 | |
find . -name "*.xml" -exec sed -i.bak -E "s/Copyright .c. 2013/Copyright (c) 2012/g" {} \; | |
find . -name "*.xml.template" -exec sed -i.bak -E "s/Copyright .c. 2013/Copyright (c) 2012/g" {} \; | |
find . -name "*.php" -exec sed -i.bak -E "s/Copyright .c. 2013/Copyright (c) 2012/g" {} \; | |
find . -name "*.css" -exec sed -i.bak -E "s/Copyright .c. 2013/Copyright (c) 2012/g" {} \; | |
find . -name "*.js" -exec sed -i.bak -E "s/Copyright .c. 2013/Copyright (c) 2012/g" {} \; | |
find . -name "*.phtml" -exec sed -i.bak -E "s/Copyright .c. 2013/Copyright (c) 2012/g" {} \; | |
find . -name "*.html" -exec sed -i.bak -E "s/Copyright .c. 2013/Copyright (c) 2012/g" {} \; | |
# Delete all the backup files that were created | |
find . -name "*.bak" -exec rm {} \; |
If all you're needing is a diff, try this:
diff -qrI '@copyright' /path/to/mage-v1 /path/to/mage-v2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One last follow up. It's not strictly UTF-8 characters that are tripping up
sed
. Per the previous Stack Overflow questions,sed
will obey the encoding set inThat means it's fine with UTF-8. The "real" problem is those files aren't UTF-8 encoded. BBEdit reports them as "Western (Max OS Roman)" on my system (— but text encoding is complicated).
So, a better explanation of what's going wrong is those files contain characters that aren't technically valid for their encoding. Our text editors and browsers have heuristics to do something smart when they encounters this — but
sed
's a tool written by c programmers to operate directly on bitstreams (sed
stands fors
treamed
itor). Whensed
encounters those characters, it gets upset and bails rather than making a wrong "heuristical" guess.Ultimately not useful to our task at hand, but interesting if you're interested in C programming.