
Learn Awk by Example (2019) - thewhitetulip
https://github.com/thewhitetulip/awk-anti-textbook/
======
csydas
As much as I admire this, I believe that The AWK Programming Language is
probably the best resource for just learning awk.

[https://en.wikipedia.org/wiki/The_AWK_Programming_Language](https://en.wikipedia.org/wiki/The_AWK_Programming_Language)

I read it on a whim after hearing the accolades awk would get from people when
it came to text munging, and as I have to do a lot of it at work, I figured
I'm bound to come across practical situations for my own purposes once I get a
few basics from the guide.

And sure enough, I did. I love the original simply because it helped me
understand the scope of tasks I should look at for awk; I could just think
about my own difficulties with handling large amount of text data (mostly very
verbose logging), and then create a workflow in awk that mimicked my actual
work, but vastly expedited.

The article linked is nice and cute, but it more or less is a rehash of the
topics covered in The AWK Programming Language, which isn't bad (more data is
good), but I feel the original handles the explanations far far better and
helps you to really understand what awk is good at and when to attack with awk
versus when your task is better suited for something else.

~~~
tjoff
Since threads like these are always filled will praise about the book, I
started reading it and was quite excited about it.

The book is excellent, but the target audience it is written for won't read it
today. It is written for people that pretty much have never programmed
anything before. For someone that is knowledgeable of computing in general, or
programming and possibly even already have a vague idea of what AWK is, it
becomes very verbose.

I get it, it is a cool way to at the learn some history and the context of
which it was created. But if the sole goal is to quickly learn AWK I feel that
it is quite ineffective and it becomes hard to focus when there is so little
relevant content.

I lost focus and didn't finish.

I would like to pick it up again in a less stressful time. The thing that
holds me back is that I'm not sure I will get enough use of it to be able to
remember it. It might be a simple language but it is very different from
anything that at least I use today, and if I have to relearn it every other
time I use it then there isn't much point to it.

~~~
thewhitetulip
Are you talking about gawk manual or the submission?

~~~
tjoff
The AWK book discussed by grandparent,
[https://en.m.wikipedia.org/wiki/The_AWK_Programming_Language](https://en.m.wikipedia.org/wiki/The_AWK_Programming_Language)

------
asicsp
Nice! A few suggestions if I may:

* please consider using the same prompt for all examples, a few of them start with `code` while some others start with `awk book` and some do not have any prompt at all

* split long chapters into smaller sections plus add section headings as links at the start of chapter

* please please please avoid parsing ls [1] you could either reuse `sales.csv` or create another sample file instead of using `ls` as source of input... for example, your `ls -l | awk '$NF ~ /c/ {print}'` example will not work if a file is name `code xyz` (note the space)

Also, I have a similar example based hundreds of gawk one-liners [2] tutorial,
which I'm currently working towards publishing as a book this month with
better examples, descriptions, new regex chapter, etc

[1] [https://unix.stackexchange.com/questions/128985/why-not-
pars...](https://unix.stackexchange.com/questions/128985/why-not-parse-ls-and-
what-to-do-instead)

[2] [https://github.com/learnbyexample/Command-line-text-
processi...](https://github.com/learnbyexample/Command-line-text-
processing/blob/master/gnu_awk.md)

~~~
thewhitetulip
Thank you for your suggestions. I'll keep them in mind while updating tutorial

------
codecowboy
I think this is deliberate subversive misdirection from the Golang mafia

~~~
thewhitetulip
Hahaha I can assure you that it is not.

I have written a few books and I copied the text files from my Go book.

Apologies.

I didnt get to creating a gitbooks for this book.

I am planning to statiscally generate a website and host it via github itself,
rather than gitbooks.

~~~
bloopernova
You wrote a great tutorial, I'm definitely saving this and sharing it with any
colleagues who need help with command line file mangling.

~~~
thewhitetulip
Thank you very much.

------
jamestomasino
I love having a variety of these types of sites available for a new language.
Different learners will react well to different styles. My personal favorite
is AWK in 20 Minutes: [http://ferd.ca/awk-
in-20-minutes.html](http://ferd.ca/awk-in-20-minutes.html)

The AWK Programming Language book is also great.

Nice work.

~~~
thewhitetulip
Thank you! Yes, everyone learns in their own way. I am happy that you found
the book useful

And yes. The official boom is very good and in depth

------
emehrkay
Im on the second page of this book and it is presented in a way that makes me
want to use awk right now. I really like how this is written, it does a great
job of presenting a base idea and building on it. @thewhitetulip did you plan
out all of the example topics before writing each page in the manuscript?

~~~
thewhitetulip
Thank you very much!

My idea was to get the reader started as quickly as possible. I wrote a book
which I hoped existed when I was learning awk.

I mostly learnt awk from the gawk manual and internet. So I wrote down a long
list of awk commands while I learnt.

Then I sorted them according to concept and then wrote the text surrounding it

------
saagarjha
Your Gitbooks link seems to go to something about Go?

~~~
japanoise
Yes I'm getting that too. It leads to
[https://thewhitetulip.gitbooks.io/webapp-with-golang-anti-
te...](https://thewhitetulip.gitbooks.io/webapp-with-golang-anti-
textbook/content/)

------
vpip
This has taught me something useful in a short space of time, thank you.

~~~
thewhitetulip
You are very welcome!

------
known
[https://archive.vn/mmd80](https://archive.vn/mmd80) is also good

------
kazinator
The "Read Online" link mistakenly points to something about Golang, not Awk.

