Systems & CLI · Beginner

cut: Build a Column Extractor

Build a command-line tool that extracts selected fields or columns from delimited text using -f and -d flags, just like Unix cut.

Beginner4-8 hoursPythonGo

This project recreates the Unix cut utility, which pulls specific columns out of delimited text such as CSV or TSV files. You implement the -f flag to choose one or more fields and the -d flag to set the delimiter, reading from a file or from standard input so it slots into a pipeline. It is worth building because it teaches line-oriented stream processing, field splitting, and the discipline of matching an existing tool's behavior precisely, including how cut handles lines that lack the delimiter. It pairs naturally with a wc clone to build intuition for how the small Unix text tools chain together into data pipelines.

What you build

  • Extracts a single field by number with the -f flag
  • Extracts multiple fields specified as a list like -f 1,3,5
  • Sets a custom delimiter with the -d flag, defaulting to tab
  • Reads from a named file or from standard input for piping
  • Preserves field order as requested and joins output with the delimiter
  • Handles lines that do not contain the delimiter gracefully
  • Streams input line by line so it works on large files

What it teaches

  • Line-oriented stream processing
  • Splitting strings on a configurable delimiter
  • Parsing flag arguments including comma-separated lists
  • Reading from files and standard input interchangeably
  • Matching a reference tool's exact behavior and edge cases

Sign in to open the build guide

Free account. Get the step-by-step build and every resource link.

Sign in to continue

Take it further

  • Support field ranges such as -f 2-4 and open-ended ranges like -f 3-.
  • Add a -c flag that cuts by character position instead of by field.
  • Add an option to treat repeated delimiters as a single separator.

More like this

All projects