Created
October 24, 2012 08:50
-
-
Save ja-mf/3944911 to your computer and use it in GitHub Desktop.
replace a block of text multiple files
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
#!/bin/bash | |
# replace the line 1 and the first match of STRING with new_code | |
# of all files in find. | |
for file in $(find . -type f -name '*'); do | |
mv $file $file.old | |
cat new_code <(sed '1,/STRING/d' $file.old) > $file | |
rm $file.old | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment