AWK is a standard command line tool for processing text. It is available on Unix-based systems like Linux and Mac OS X.

The strange name is simply an acronym of the three creators’ initials.

AWK fills a cool niche where bash builtins like grep and sed have some limitations.

For example, it can be tricky to process text output that is separated by whitespace such as tabs. I have encountered differences writing scripts which run differently on Linux and Mac systems using the same bash commands (due to the GNU vs. BSD lineage).

AWK is a great tool to overcome this type of OS discrepancy. For example, if you use docker you know docker images prints a whitespace-separated list of all your local images, with the image ID being in the 3rd column.

This nifty script will search the docker images output against a user-provided string. awk '{print $3}' will output the image IDs only, and that output is piped into docker rmi remove the images.

This task sounds simple but it might prove tricky using standard bash tools like grep, sed and tr when running on different OS’s and dealing with whitespace-separated content.

IMAGE_NAME="your_image_name_here"
docker images | grep --color=never "$IMAGE_NAME" | awk '{print $3}' | xargs docker rmi -f