fork download
  1. #!/bin/bash
  2. s="geo:FR, host:www.example.com"
  3.  
  4. host="$(sed -n 's/.*host:\([^[:space:],]*\).*/\1/p' <<< "$s")"
  5. geo="$(sed -n 's/.*geo:\([^[:space:],]*\).*/\1/p' <<< "$s")"
  6. echo "$host and $geo"
  7.  
  8.  
  9. s="host:www.example.com, geo:FR"
  10. host="$(sed -n 's/.*host:\([^[:space:],]*\).*/\1/p' <<< "$s")"
  11. geo="$(sed -n 's/.*geo:\([^[:space:],]*\).*/\1/p' <<< "$s")"
  12. echo "$host and $geo"
  13.  
Success #stdin #stdout 0s 19640KB
stdin
Standard input is empty
stdout
www.example.com and FR
www.example.com and FR