Shell scripting: an “awk” intro

Among personal sharing, the tutor introduces the shell scripting language “awk”.

 
Am I a geek? In my home town, I probably qualify. However, in a large centre, I’d be “geek-lite” at best. I do program computers, but it’s not my profession. My degree is in math, not comp-sci. Somehow, the scientists – especially those in computer science – have first right to geekness.

Likely, one trait counting against my geekness is the fact that I don’t use the calculator app on the computer. Even when I’m at the computer, I use a hand-held calculator to crunch numbers.

But what, I asked myself today, if I could calculate from the terminal? That would appeal. Off I went to find out about it.

What I found was the website thegeekstuff.com. What an exciting resource it is! Sasikala has an article there about using awk to do math from the command line. Here are couple of tasty examples:

1)In the Linux terminal, the command

awk ‘BEGIN{print sqrt(78)}’

will give the square root of 78:

8.83176

2)In the Linux terminal, the command

awk ‘BEGIN{print log(14)}’

will give the natural log of 14 (aka, ln14):

2.63906

In life, we all need to make peace with some realities. I have to face the fact that I’m probably too old to ever reach true geekness. Yet, I’m not giving up.

I’m anxious to talk more about awk scripting:)

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Leave a Reply