I use a Linux (Ubuntu) bash. When I ping an address dirrectly - all work fine. But when I use it with a variable that gets it's value from calculation - it fails.
what am i doing wrong?
network=`ip r | grep default | awk '{print $3;}'`
echo $network # prints: 10.0.0.138
ping $network # prints: ping: 10.0.0.138: Name or service not known (ERROR???)
ping 10.0.0.138 # prints: PING 10.0.0.138 (10.0.0.138) 56(84) bytes of data. (OK)
set -xto find out what is stored in$network.$networkcausing trouble. Rather thanecho $network, tryprintf %s "$network" | xxdand see what that shows.