fork download
  1. #!/bin/bash
  2. s="This is the first line 1
  3. Here is password=SECRET second line 2
  4. Here is third line 5
  5. more 6"
  6.  
  7. res="Result: '$(sed -e '1h;2,$H;$!d;g' -e 's/.*password=.*//' <<< "$s")'"
  8. echo "$res"
  9.  
  10. res3="Result: '$(sed ':a;N;/password=/!ba;d{:b;N;d;bb}' <<< "$s")'"
  11. echo "$res3"
  12.  
Success #stdin #stdout #stderr 0s 4428KB
stdin
Standard input is empty
stdout
Result: ''
Result: ''
stderr
sed: -e expression #1, char 22: extra characters after command