jhintu jhintu - 1 year ago 118
Bash Question

Extract string using : as delimiter in shell

I have a string

"inet6 addr: 2620:cb:0:b007::23c3/112 Scope:Global",

and I want to extract only


from the above string.

How can I extract the substring using cut/sed/awk command.

Answer Source

I am too new in shell but with cut command, it would be like:

   cut -f2-7 -d":" | cut -f1 -d "/"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download