Does bash
have a built-in function/capability to split a string per separator symbol? For example, I'd like to split the following strings
10.10.10.1:7000
10.10.10.2:8000
...
in two parts: the first with IP address, the second with the port. I could use sed
or awk
for this, but I'm curious if bash
already has something for this?
Thanks.
UPDATE With a suggestion from @Charles Duffy I came up with the following:
addr="10.10.10.1:7000"
arr=(${addr//:/ })
echo IP ${arr[0]}
echo Port ${arr[1]}