Showing posts with label gawk. Show all posts
Showing posts with label gawk. Show all posts

Sunday, 3 August 2008

Linux Awk Example

Here is a 'Hello World!' example written using Awk in Linux. You can compare it to this example for Windows.

awk 'BEGIN { print "Hello world!" }'

Useful AWK Links

Here are some useful links which will help you in learning AWK.
  • This is a link to the AWK page on Wikipedia.
  • The GAWK manual is here.
  • A link to a forum post which solved a problem I was having.

Saturday, 2 August 2008

AWK Windows Examples

Okay, here's the first; a simple Hello world example.

awk "BEGIN { print \"Hello world!\" }"

The above program will print Hello world! on the screen.

Linux users should notice the use of double quotation marks at the beginning & end of the script. Also notice how the quotations in the braces have had to be 'cancelled-out' with backslashes.

If anyone wants to know why I've become interested in Awk, it was based on me reading this thread on the Ubuntu Forum.

AWK, GAWK, MAWK etc...

I'd been hearing about 'awk' for a longtime on the Ubuntu forum. It's a simple command-line tool that you can use for searching through text files. I've just downloaded the Windows version which can be found here.

The biggest difference between the Linux version & the Windows version so far has been in how you enter quotation marks for the tasks.

Single for Linux '
Double for Windows "

I'll try & post some usage examples later on.