Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Stuff
- Pattern
- Stuff
- patternline=$(grep -n "Pattern" "/my/file" | cut -f1 -d:)
- firstcut=$(($patternline -1))
- firstpart=$(sed -n 1,"$firstcut"p "/my/file")
- secondpart=$(sed -n ''"$abspathcomment"',$p' "/my/file")
- # Indentation intentional as snippet is nested within an IF statement
- text=$(cat <<EOF
- Text I want to insert with one leading and two trailing new lines
- EOF
- )
- echo "$firstpart$text$secondpart" > "/my/file"
- Stuff
- Text I want to insert with one leading and two trailing new lines
- Pattern
- Stuff
- Stuff
- Text I want to insert with one leading and two trailing new linesPattern
- Stuff
Add Comment
Please, Sign In to add comment