Linux + C – Some Useful Filters

Soon we'll talk about perhaps the most powerful programmable filter ever conceived (the scripting language AWK), but first let's look at a few other common filters and their uses. More The filter more is a program that lets us print output one screen at a time. If you've ever run a diff between two files or

Linux + C – Your New Friend, Awk

In modern internet lingo, awk is a synonym for awkward or abnormal. However, the Linux tool awk (and its brethren, gawk and nawk) are anything but awkward. Awk - the programmable filter So far, we've looked at a set of filters that perform fairly singular tasks. LESS and MORE are designed to filter output to the

Linux + C – AWK for Beginners

Now that we know how valuable awk is, we can start to look at how we use it. The Three Phases There are three stages of an awk script: BEGIN - happens exactly once at the start of the program END - happens exactly once at the end of the program ...and the main loop We usually use the BEGIN

Linux + C – Awk Example: Line Counter

Like most things, learning awk is much easier with examples. Today we'll look at a simple awk script which counts lines of code based on their type. The Code: linecount The following code uses a lot of regular expressions to determine the nature of a line. There are three formats for these if statements: if($0 ~ /REGEX/)

Linux + C – Some other great tools

Well, we've pretty much run the gamut with Linux and C. However, there are a few other excellent tools you should know about. Doxygen Documenting code is a pain for most people. After months and months of diligent coding, they have to go back and create meaningful descriptions of all their library functions and how they

Quickie: Configuration Headers

We all know (or at least we should know) that we can use #define to create macros that replace names with values during the preprocessor phase of compilation. Sometimes, it's very important for us to have the ability to change large amounts of code very quickly, because we have a new size limit for