Environment Variables in Unix

Each process in Unix has its own set of environment variables. They're called environment variables because the default set of such variables consists mostly of session-wide variables used for configuration purposes.

From the point of a Unix shell though, environment variables can be accessed the same way as any other variable.

[Read more…]

Unix scripts: basic arithmetic operations

As I was writing the Time and date in Unix scripts post last week, I've realized that there's one really useful feature of Unix shell scripting which I haven't covered on my pages here: it's the double bracket parenthesis which allows you to evaluate arithmetic expressions.

Basic arithmetic calculations in Unix scripts

In most scenarios, your script will need only basic arithmetic operations: summing or subtracting numbers, multiplying or dividing them. Using only these operations, you'll be able to implement all sorts of counters and calculate percentages or any other progress indicators you may need.

[Read more…]