Unix Utilities

The gist: clone simple, tried and true Unix commands.

When working with the command line, it's likely you have used of the core Unix programs like grep, cat, less, tail, or sort.

A great learning exercise is to rewrite those existing tools. Who knows, you might end up making a faster or better version.

One of the main concepts in Unix is being able to pipe data and chain together the commands. cat foo.txt | grep bar, that sort of thing. As part of rewriting these commands, you'll need to learn about stdin, stdout, and more.

Here are some simpler utilities that would be good candidates for building:

  • cat — output the contents of a file, line by line, to stdout
  • ls — list the files of the current or passed in directory
  • grep — search through the contents of target files for a match
  • less — read-only file viewer, particularly useful for longer files
  • sort — order lines alphanumerically
  • tail — print last n lines of a file, can follow output with -f, useful for logs
  • wc — displays the number of lines, words, and bytes in a file