bash - Reverse order of a string -


i want "reverse" order of 4 octets (bytes) make ip address.

suppose have ip:

202.168.56.32 

i need convert into:

32.56.168.202 

and remove first octet in reversed ip. final result:

56.168.202 

my attempts:

echo 202.168.56.32 | rev 

but it's returning :

23.65.861.202 

this should trick:

echo 202.168.56.32|awk -f. '{print $3"."$2"."$1}' 

you bash arrays:

ip=202.168.56.32 parts=(${ip//./ }) echo ${parts[2]}.${parts[1]}.${parts[0]} 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -