Search This Blog

Shell Script: How to parsing server address string

#!/bin/bash

# $1 is wilson@site90.net:8000
i=`expr index $1 @`
user=${a:0:$((i-1))}
echo $user

j=`expr index $1 :`
host=${1:$i:$((j-i-1))}
echo $host

port=${1:$j:((${#1}-j))} 
echo $port

See this post for detail.

No comments:

Post a Comment