title: How to test if link is up in bash script
body: <p>using this script I am trying to detect if there is a network link. I am failing in putting multiple commands in one line (ethtool...). What to do?</p>
  
  <pre><code>#!/bin/bash
  
  COMMAND="( /sbin/ethtool eth0 ) | ( /bin/grep \"Link detected: yes\" ) | ( wc -l )"
  ONLINE=eval $COMMAND 
  
  if $ONLINE; then 
      echo "Online"
  else
      echo "Not online"
  fi
  </code></pre>