Answer the question
In order to leave comments, you need to log in
Bash, head and tail: Unable to open for reading?
Good day everyone.
I would be very grateful if you help.
There is a bash script to analyze those. system states, code listing:
#! /bin/bash
touch logfile
while true
do
echo $(date) >> logfile
var=$(uptime | tail -n –c17 | head -n –c4)
cpuload=$(($var*1))
echo current cpu load is $cpuload % >> logfile
echo $(df –h / | grep /) >> logfile
temp=$(cat /sys/class/thermal/thermal_zone0/temp)
echo “current temp is $((temp/1000)) c” >> logfile
echo “----------------------------------------” >> logfile
sleep 1
done
Answer the question
In order to leave comments, you need to log in
one error left on line 7: ./analiz.sh: line 7: *1: syntax error: expected operand (invalid token "*1")
cpuload=$(($var*1))
cpuload=$[var*1]
cpuload=$[${var:=999}*1]
cpuload=$(($var*1))
Why do you even need a construction with multiplication by 1? What's the point?
Make a numeric variable? So do it like this
declare -i var
And so, most likely $var was not set for you at that moment, so it tries to multiply the void by 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question