i am new to SunOS unix system. i want to store the uptime and convert it into minutes in a shell script. below is what i used inside script.
hrs=`uptime | awk '{print \$5}' | sed 's/[:,]/ /g' | awk '{print \$1}'`
mins=`uptime | awk '{print \$5}' | sed 's/[:,]/ /g' | awk '{print \$2}'`
uptimesecs=$(($mins*60)))
and error what i got in script.
can anyone help me with the syntax
You are overquoting the
$
s in theawk
scripts:You're also doing more work than is necessary. Get the uptime once:
Then split the value on a
:
using the shell itself.