Last active
August 29, 2015 14:07
-
-
Save innermond/a5046ffc6aacfea858df to your computer and use it in GitHub Desktop.
Insert lines into certain files. After first and before last line
This file contains hidden or 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 | |
| # insert text lines after first line and before last line of file | |
| # $1 = a glob expression like */assets/*.css | |
| # $2 = a literal to be inserted after first line | |
| # $3 = same as above but inserted before last line | |
| for f in $1; do | |
| eval "sed -ri '1 s/(.*)/\1\n$2; $ s/(.*)/$3\n\1/' \"$f\"" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment