Last active
March 31, 2016 18:11
-
-
Save pfaffman/8644399 to your computer and use it in GitHub Desktop.
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 | |
# fixnames | |
# Jay Pfaffman <jay@pfaffman.com> | |
# Available from https://gist.github.com/pfaffman/8644399 | |
if [ $# -lt 1 ] | |
then | |
echo "Usage " $0 files | |
echo " Replaces names (or any words) in files passed on the command line." | |
echo " Edit below to change what names get replaced." | |
exit | |
fi | |
# According to: http://stackoverflow.com/questions/17382272/beginning-and-end-of-words-in-sed-and-grep | |
# on OS X you'll need to use [[:<:]] and [[:>:]] for word boundary. | |
# Using \b or \< just doesn't work. | |
# For each first and last name, duplicate the sed line below to replace in all | |
# of the documents passed on the command line. | |
# Sites like http://listofrandomnames.com/ will give you lists of names. | |
for file in $* | |
do | |
echo -n "Processing " $file ". . . " | |
# Stick in as many names like these as you need to | |
# Whatever is in the first field between the /'s will be replaced by the second field. | |
sed --in-place -e 's/\<OLDNAME\>/NEWNAME/g' $file | |
echo done. | |
done | |
exit | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment