Shell programming
A Linux shell is a command line interpreter that provides a user interface for a system itself. It can be used to install programs (apt-get install
) or even for some programming, including conditions, logic, or loops. Linux provides many different shells. Very often, the Bourne shell is used, which was developed in the 70s by Stephen R. Bourne. This shell provides input and output redirection, pipes, background processes, and much more. For all Linux systems, a Bourne-compatible shell in the /bin/sh
directory is available.
Checking the Banana Pro temperature
Let's start our first shell program using these steps:
- Edit a file called temperature and place the following content in it:
#!/bin/sh cat /sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input
- Save the file afterwards and make it executable:
chmod 775 temperature
- Execute this file by typing this:
./temperature
My output shows 36200
, which is the Banana Pro temperature multiplied by 1,000. The first line of the...