Basic question about Bash scripting with Weather Cape

So I am the proud owner of a weather cape and beagle bone white and a newb when it comes to bash scripting.

Lets say I want to otput to the command line the relative humidity as a percentage using a bash script.

Getting the relative humidity is as easy as cat /sys/bus/i2c/devices/1-0040/humidity1_input

How do I assign this value to a variable in a bash script so that I can manipulate it (specificall divide by 1000 to express as a percentage)?

humidityInput=/sys/bus/i2c/devices/1-0040/humidity1_input
echo $humidityInput

gives me /sys/bus/i2c/devices/1-0040/humidity1_input

I have tried putting paranthesis, quotes, and single quotes around “/sys/bus/i2c/devices/1-0040/humidity1_input” but can’t get bash to assign the value of the file to the variable.

Any of you linux gurus want to help a new out?

Thanks in advance!

Jason

First get any linux/unix book real soon now. If you do not know how to do this, you will stumble in many other things...
You can find many used book very cheap.

HI=`cat /sys/bus/i2c/devices/1-0040/humidity1_input`

Using backquotes.
Besides bash does not make calculations in floating point.
You will need to use another tool, and there you have other reason to get an Unix/Linux book (not only a Bash book).

Greetings

Paulo Ferreira

There are even books out there just for bask scripting, some advanced some intro. O’Reilley has at least one I am pretty sure

Intro http://shop.oreilly.com/product/9781565923478.do

solutions and examples http://shop.oreilly.com/product/9780596526788.do

bash scripting sorry about the typo.