awk cheat sheet

I love cheat sheets. I have at least 30 in front of me at the moment scattered throughout my desk: awk cheat sheet, vt100/ansi screen terminal emulation keyboard mapping cheat sheet, emacs command line editing mode cheat sheet, ethernet, ip and tcp header layout cheat sheets and many many others. I am glad that I can share the cheat-sheets with you so you can become a better developer! I have made some 15 out of 30 cheat sheets myself and I will make them available for download in the future posts.

Someone might say that looking the information up in a man or info page, manual or Google is equivalent to looking it up on a cheat sheet, if not better. I disagree.

First of all it is usually, but not always, takes more time to find where in the documentation the particular thing is located but in the cheat sheet you have it right in front of you. For example, suppose you were C programmer and forgot how to print a floating point number, you'd type `man 3 printf' and quickly find the answer. That's fine - it's as fast or even faster than looking something up in a cheat sheet but that's just because you knew exactly what you were looking for! But let's look at Joe Random who just began learning gawk programming language and at the moment wants to replace a part of a string with another string. He'd probably already have the manual open and would start going through it looking for string functions. It would take him a good minute or so before he finds the correct place and reads how the function works. Now, if he had a cheat sheet, like the one I created here, he'd have all the string functions in front of him and he would quickly locate that it is gsub or gensub. He'd find not only that but also all the other string functions and next time he has a problem he might remember the right function subconsciously.

What I want to emphasize is that the cheat sheets are not for NOT remembering things and just looking them up hundreds of thousands of times and never actually learning them but are FOR remembering and learning new things faster.

It is also interesting to find what technologies you have not used for a while because the cheat sheets pile up in most recently.

I made this cheat sheet in Microsoft Word because I am not that good with TeX, particularly formatting data so it looked nice.

So the awk cheat sheet is available in .doc and .pdf. I will usually post the cheat sheets in these two formats.

This cheat sheet contains:

  • Predefined Variable Summary, which lists all the predefined variables and which awk versions (original awk, nawk or gawk) have it built in,
  • GNU awk's command line argument summary,
  • I/O statements,
  • Numeric functions,
  • Bit manipulation functions,
  • I18N (internatiolization) functions,
  • String functions, and finally,
  • Time functions.

If you notice any inaccuracies, mistakes or see that I have left something out, leave a comment.

Download AWK Cheat-Sheet

Download link: awk cheat sheet (.pdf)
Downloaded: 245066 times

Plain Text (.txt):
Download link: awk cheat sheet (.txt)
Downloaded: 159251 times

Microsoft Word 2000 format (.doc):
Download link: awk cheat sheet (.doc)
Downloaded: 18128 times


Ian Butler Permalink
August 16, 2007, 18:55

Your awk cheat sheet will come in handy. Many thanks for taking the time to create and to share it.

buccia Permalink
August 30, 2008, 17:26

Thanks for creating and sharing this.

April 10, 2009, 02:29

Great cheat sheet. And for yet for information on awk see

April 16, 2009, 13:49

Great cheat sheet, even handy if you already have awkcard, the one that comes with the gawk distribution.

Taking a hint from the latter, if it isn't too hard perhaps you could highlight text that applies only to gawk.

Saravanan Permalink
August 13, 2009, 06:33

Awesome.. Thanks Man.. The cheat sheet is my bible for AWK. I have recommended the sheet for my friends too.

Carla Permalink
August 21, 2009, 10:07

I'm a total newbie in unix, though I have considerable programming experience in another environment... I totally agree with your motto "good coders code, great reuse"!!
Thanks a lot

ramkishor Permalink
July 26, 2010, 12:08

i want to set display

January 26, 2011, 12:44

I really liked your sed cheatsheet, and the one-liners explained, but not so much the awk one. If anyone else is looking, I'd recommend this one:

yasha Permalink
May 18, 2011, 09:21

Thnks for the cheat sheet. I found them quite interesting

Dick Newell Permalink
May 09, 2012, 13:33

Thanks for posting this! It is a big help.

Leave a new comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "linux_4": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.