fork download
  1. #!/bin/bash
  2. url='example.com:7000'
  3.  
  4. IFS=: read host port _ <<< "$url:8080"
  5.  
  6. # check host and port values
  7. declare -p host port
  8. echo '------'
  9.  
  10. url='example.com'
  11.  
  12. IFS=: read host port _ <<< "$url:8080"
  13.  
  14. # check host and port values
  15. declare -p host port
  16.  
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
declare -- host="example.com"
declare -- port="7000"
------
declare -- host="example.com"
declare -- port="8080"