Skip to content

Instantly share code, notes, and snippets.

@ja-mf
Created October 24, 2012 08:50
Show Gist options
  • Save ja-mf/3944911 to your computer and use it in GitHub Desktop.
Save ja-mf/3944911 to your computer and use it in GitHub Desktop.
replace a block of text multiple files
#!/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