fork download
  1. #!/bin/bash
  2.  
  3. match="string_I_want_to_match"
  4.  
  5. read -r -d '' str_i_want_above <<- 'EOF'
  6. I
  7. Want
  8. This
  9. Above the match
  10. EOF
  11.  
  12. sed "/$match/i \\
  13. ${str_i_want_above//$'\n'/\\$'\n'}
  14. " <<< "$match"
Success #stdin #stdout 0.01s 5532KB
stdin
Standard input is empty
stdout
I
Want
This
Above the match
string_I_want_to_match