Created
July 5, 2016 02:27
-
-
Save kevinhooke/982891f622701ce70de8bef630fc9b9b to your computer and use it in GitHub Desktop.
bash prepend and append content to a number of matching 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 | |
for f in $(find . -name "*.jsp") | |
do | |
echo "Updating file: $f" | |
#prepend: note BSD requires an empty '' param to sed -i | |
sed -i '' '1s/^/new line1\ | |
new line2\ | |
new line3\ | |
/' $f | |
#append trailing content | |
echo "new line 4 | |
new line5 | |
new line6" >> $f | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment