#!/bin/bash
s="This is the first line 1
Here is password=SECRET second line 2
Here is third line 5
more 6"

res="Result: '$(sed -e '1h;2,$H;$!d;g' -e 's/.*password=.*//' <<< "$s")'"
echo "$res"

res3="Result: '$(sed ':a;N;/password=/!ba;d{:b;N;d;bb}' <<< "$s")'"
echo "$res3"
