R
R
Ruslan2015-09-20 15:22:24
linux
Ruslan, 2015-09-20 15:22:24

How to split a string into bash variables?

Tell me how to split a string into variables in bash.
The string protocol1:///protocol2:example.com
Get protocol2 and example.com

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Fedoseev, 2015-09-20
@iRusel

field1=`echo $str | cut -f 3 -d':'`
fileld2=`echo $str | cut -f 2 -d':' | tr -d '/'`
like so

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question