I invite you to upgrade to a paid subscription. Paid subscribers have told me they appreciate me creating the programming projects and would like to see more of them in the future. Hi, this is John with this week’s Coding Challenge. 🙏 Thank you for being a subscriber, I’m honoured to have you as a reader. 🎉 If there is a Coding Challenge you’d like to see, please let me know by replying to this email📧 Coding Challenge #116 - AwkThis challenge is to build your own version of awk, the classic text processing language. Awk was created in 1977 by Alfred Aho, Peter Weinberger, and Brian Kernighan (the name comes from their initials). It’s a small but remarkably powerful language designed for processing structured text data. Awk reads input line by line, splits each line into fields, and applies pattern-action rules to produce output. It sits in a sweet spot between sed (which is great for simple substitutions) and a full programming language like Perl or Python. Despite being nearly 50 years old, awk remains one of the most useful tools in a developer’s toolkit. You’ll find it in shell scripts, data pipelines, and one-liners across every Unix system in the world. Building your own awk will teach you about lexing, parsing, interpreters, and the design of small domain-specific languages. If You Enjoy Coding Challenges Here Are Four Ways You Can Help Support It
The Challenge - Building Your Own AwkIn this challenge you’re going to build your own version of the awk text processing tool. Your tool will read input line by line, split each line into fields, match lines against patterns, and execute actions -- producing output that is compatible with the standard POSIX awk utility. Awk programs are built from pattern-action rules that look like this: Step ZeroIn this introductory step you’re going to set your environment up ready to begin developing and testing your solution. Choose your target platform and programming language. I’d encourage you to pick a language you’re comfortable with for building interpreters. You’ll be writing a lexer, a parser, and a tree-walking interpreter, so a language with good string handling and data structures will make your life easier. Before you start coding, have a read through the POSIX awk specification to get a feel for the language. Don’t worry about understanding every detail -- we’ll work through the features step by step. It’s also worth playing with the system Create a test file to use throughout the challenge. Here’s one you can use:
Step 1In this step your goal is to support the basic print action with field splitting. Your tool should read input from a file (or stdin if no file is given), split each line into fields on whitespace, and support the At this point, you only need to handle a bare action block with no pattern -- meaning the action runs for every line of input. Focus on getting the core loop right: read a line, split it into fields, execute the action, move to the next line. Testing: Run these commands and compare against the system
The first two should print every line. The third should print just the first name from each line. The fourth should print the name and city, separated by a space (the default output field separator). The fifth should read from standard input and print each line. Your output should match Step 2In this step your goal is to support the The Implement the built-in variables Testing: Create a CSV-like test file and test with custom separators:
The first command should print just the names from the colon-separated file. The second should print line numbers alongside names. The third should print the number of fields on each line. Compare all output against the system Step 3In this step your goal is to support patterns, comparison operators, and regular expression matching. Awk’s power comes from its pattern-action model. A pattern can be a comparison expression (like Implement comparison operators ( Your program should support multiple pattern-action rules. Awk checks every rule for every line, so a single line can trigger multiple actions. Testing:
The first should print names of people older than 25. The second should print “John”. The third should print lines where the first field starts with A or J. The fourth should print a header, all names with ages, then “Done”. The fifth should set the field separator to colon inside Step 4In this step your goal is to support variables, arithmetic operators, and assignment operators. Awk variables are dynamically typed -- they can hold strings or numbers and convert between the two as needed. Uninitialised variables default to Implement arithmetic operators ( Testing:
The first should print the sum of all ages. The second should print names with doubled ages. The third should concatenate fields with text. The fourth should print 1024. Compare against Step 5In this step your goal is to support control flow: Also implement Testing:
The first should label people as senior or junior based on age. The second should print every field on its own line. The third should skip Bob’s line and print everything else. The fourth should print only the first three lines. The fifth uses the ternary operator to produce the same senior/junior labelling in a different style. Compare against Step 6In this step your goal is to support associative arrays and the Associative arrays are one of awk’s most powerful features. They’re indexed by strings (not just integers) and can be used to count, group, and aggregate data. Implement the Testing:
The first should count how many people live in each city. The second should check if Bob exists and print his age. The third should delete Bob and print the rest. Note that Step 7In this step your goal is to support the Implement Implement these built-in string functions: Testing:
The first should print a neatly formatted table. The second should print the length of each name. The third should print the first three characters of each name. The fourth should replace all “o” characters with “0” in the first field. The fifth should print names in uppercase. Compare against Step 8In this step your goal is to support user-defined functions and built-in arithmetic functions. Implement user-defined functions with the syntax Implement the built-in arithmetic functions: Testing:
The first should print each name alongside the greater of their age or 30. The second should print 5 random numbers. The third should print names with the integer square root of their age. Compare against Step 9In this step your goal is to support the remaining output and input features. Implement the output built-in variables: Implement the Testing:
The first should print fields separated by dashes. The second should read the program from a file and print each line with its filename. The third should use the command-line variable. The fourth should process both files and show which file each line came from. Compare against Step 10In this step your goal is to support piping output to shell commands and the Implement the pipe operator for Implement Testing:
The first should print names in sorted order. The second should print the current date. The third should read and print the test file from within a
Going FurtherHere are some ideas to take your awk implementation further:
P.S. If You Enjoy Coding Challenges Here Are Four Ways You Can Help Support It
Share Your Solutions!If you think your solution is an example other developers can learn from please share it, put it on GitHub, GitLab or elsewhere. Then let me know via Bluesky or LinkedIn or just post about it there and tag me. Alternately please add a link to it in the Coding Challenges Shared Solutions Github repo Request for FeedbackI’m writing these challenges to help you develop your skills as a software engineer based on how I’ve approached my own personal learning and development. What works for me, might not be the best way for you - so if you have suggestions for how I can make these challenges more useful to you and others, please get in touch and let me know. All feedback is greatly appreciated. You can reach me on Bluesky, LinkedIn or through SubStack Thanks and happy coding! John You're currently a free subscriber to Coding Challenges. For the full experience, upgrade your subscription.
|
#6636 WWE 2K26 v1.06 + 6 DLCs [Monkey Repack] Genres/Tags: Arcade, Fighting, Sports, 3D Companies: 2K Games, Visual Concepts Languages: ENG/MULTI6 Original Size: 129.2 GB Repack Size: 107.8 GB Download Mirrors (Direct Links) .dlinks {margi… Read on blog or Reader FitGirl Repacks Read on blog or Reader WWE 2K26, v1.06 + 6 DLCs [Monkey Repack] By FitGirl on 28/03/2026 # 66 3 6 WWE 2K2 6 v1.0 6 + 6 DLCs [Monkey ...

Comments
Post a Comment