Skip to content

Instantly share code, notes, and snippets.

@gubatron
Created May 8, 2013 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gubatron/5543946 to your computer and use it in GitHub Desktop.
Save gubatron/5543946 to your computer and use it in GitHub Desktop.
Fixing all the license headers in code recursively, changing "FrostWire(TM)" to "FrostWire(R)" in bash
#first find the files that need to be changed, and output their paths to a text file
#I use 'cut', to trim the ":" left by the grep output.
grep "FrostWire(TM)" * -R | awk {'print $1'} | cut -d ":" -f 1 > tm_replace
#then go through each file path in the text file and perform a search and replace using perl regex
for FILE in `cat tm_replace`; do perl -p -i -e 's/FrostWire\(TM\)/FrostWire\(R\)/g' $FILE; done
@ragol
Copy link

ragol commented May 8, 2013

You can replace the whole first line (grep command) with grep -l > tm_replace

You could skip it altogether if you don't need to preserve timestamps of files. Just run sed or Perl on all files. They would change only matching files anyway. Otherwise you scan all matching files twice.

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