1

When I run the script I get the following errors. What am I doing wrong here please? Any help appreciated- Bash Newbie

Error:

line 12: 0=1: command not found
line 13: 0=1: command not found

My Script:

count_raw=0
avg_raw=0

$count_raw=1
$avg_raw=1

echo "count_raw=$count_raw"
echo "avg_raw=$avg_raw"
2
  • 6
    remove the dollar before count_raw and avg_raw Commented Jul 23, 2015 at 10:25
  • That fixed it thanks- Commented Jul 23, 2015 at 10:59

1 Answer 1

1

= is an assignment operator when found free and $ holds value (not only in USA but in bash too) of a variable.

So when you say: $var=1, you're essentially trying to type a random string (0=1 in your case) in bash and bash doesn't like that. Look at the one-liner below that shows one example where you'd type in $var=1 and bash would be able to process it:

var=1; if [[ $var=1 ]]; then printf "Congrats! You have learned the difference between variable assignment and variable comparison in the ${var}st attempt.\n"; fi;
Sign up to request clarification or add additional context in comments.

1 Comment

Very good, amusing and also answered the question to a T. Thanks Donbhupi

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.