fork(1) download
  1. #!/bin/bash
  2. s="some.dns.com
  3. up 720 days,
  4. some version
  5. several lines of disk space information, between 14 and 16 lines
  6. Connection to 10.1.1.1 closed.
  7.  
  8. some.other.dns
  9. up 132 days,
  10. some version
  11. several lines of disk space information, between 14 and 16 lines
  12. and more lines here
  13. and here
  14. Connection to 10.1.1.2 closed."
  15.  
  16. awk -F"\n" -v RS="" '$0 ~ /up (9[0-9]|[0-9]{3,}) days/{gsub(/Connection to | closed\./, "", $NF); print $1 "\n" $NF}' <<< "$s"
Success #stdin #stdout 0s 23472KB
stdin
Standard input is empty
stdout
some.dns.com
10.1.1.1
some.other.dns
10.1.1.2