Awk Fun!

by , under Bash, Linux

Awk is a powerful toy linux users have. As explained in wiki

The AWK language is a data-driven scripting language consisting of a set of actions to be taken against streams of textual data – either run directly on files or used as part of a pipeline – for purposes of extracting or transforming text, such as producing formatted reports.

Lately, I have seen some entries in Linkedin that sentences are in binary form like that:

As a funny work, I used awk to easily transform them into human readable sentences. You may find the file here in github and the content is:

In some cases, there were no space between octets. Therefore, an extra step had to be done, parse input according to modulus 8. The new code is something like that more or less (github):

As a result, save source text to a file called source.txt (you may also use echo or cat or sth else to use in pipeline). Save first code as resolve.awk and run it:

If there is no space in source, then save second code as put_space.awk and run it: