1
syntax error: operand expected (error token is " ")

I'm getting this syntax error with my current code:

log= who | grep $1 | cut -c 30-31,33-34
echo $log

time= date | cut -c 12-13,15-16
echo $time

on=$(($time - $log))
echo $on

If I remember correctly, " " stands for null. Why am I getting this?

1 Answer 1

4

Remove the space which was just after to = symbol and put the command inside $(), so that it would parse.

log=$(who | grep $1 | cut -c 30-31,33-34)

And,

time=$(date | cut -c 12-13,15-16)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.