Can anybody explain this behaviour of the bash shell which is driving me nuts
[root@ns1 bin]# export test=`whois -h whois.lacnic.net 187.14.6.108 | grep -i inetn
Why is my echo screwed up? It is being changed by the contents of $test.
echo
$test
Because your test contains a carriage return. Remove it:
test
test=$(whois -h whois.lacnic.net 187.14.6.108 | grep -i inetnum: | awk '{print $2}' | tr -d '\r')