AWK

Tip of the Day

find command example

Another find command example

Yet another find command example

Aho, Weinberger, Kernighan

Example #1

Solutions

How Does AWK Work?

Syntax of AWK

Simplest AWK program

To take the square root

If you have two columns of data and you want to add them up

Meaning of the fields

Metacharacters and Patterns

Patterns and Regular Expression

Metacharacter Patterns
(Most often used for filename matching)

More Complex Patterns

What if I want to match to an actual metacharacter?

Pattern Matching in other UNIX Utilities

Pattern Exercise (Set 1)

Pattern Exercise (Set 2)

Review of patterns?

Matching

Suppose you had headers on the top of your file which you wanted to ignore

Removing comments #

Real Life Problem 1:
ASD Spectra Conversion

Conversion of wavelength units from nanometers to microns for a spectral file (water.ref)

Conversion AWK script

What if you have multiple files

How do we repeatedly apply the AWK script

Processing only the water files

Renaming a set of files

We need tools to extract file name components

Shell Filename Modifiers

Sample output of the shell modifiers

Renaming the water files

foreach statement can extract elements of a shell variable

Real Life Problem 2:
MODTRAN Output

What do we want?

What do we know?

Using grep to help analyze pattern

Need to Identify Unique Pattern Property

Need to skip to the value and extract the value

Putting it all together

Can be made into a shell script (get_water_vapor.csh)

From within IDL

Stripping Out Comments in IDL

What is this file?

Commented File

Comment Stripping Routine