strange echo output

后端 未结 3 934
借酒劲吻你
借酒劲吻你 2021-01-26 15:42

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         


        
3条回答
  •  星月不相逢
    2021-01-26 16:32

    Why is my echo screwed up? It is being changed by the contents of $test.

    Because your test contains a carriage return. Remove it:

    test=$(whois -h whois.lacnic.net 187.14.6.108 | grep -i inetnum: | awk '{print $2}' | tr -d '\r')
    

提交回复
热议问题