title: Get mac address in bash script (CRON)
body: <p>I am writing a script which will run on CRON DAILY</p>
  <p>my-script.sh  has following content :</p>
  <pre><code>#!/usr/bin/env bash
  mac=$(cat /sys/class/net/$((ip route show default || /usr/sbin/ip route show default )|  awk '/default/ {print $5}')/address 2&gt;&amp;1 )
  echo &quot;$mac&quot; &gt;&gt; /tmp/test.txt
  </code></pre>
  <p>Command Link : <a href="https://stackoverflow.com/questions/43512536/get-mac-address-for-alive-interface/43512673">Get mac address for alive interface</a></p>
  <p>so when i run</p>
  <pre><code>bash my-script.sh    
  </code></pre>
  <p>I get proper mac address in file test.txt</p>
  <p>but when i set cron for same  (1 1 * * * bash my-script.sh &gt; test.log 2&gt;&amp;1)
  its giving me</p>
  <pre><code>my-script.sh: line 3: ip: command not found
  my-script.sh: line 3: /usr/sbin/ip: No such file or directory
  </code></pre>
  <p>its not able to resolve</p>
  <pre><code>$((ip route show default || /usr/sbin/ip route show default )|  awk '/default/ {print $5}')
  </code></pre>