Plurrrr

Mon 16 Jan 2023

Relational shell programming

Unix is a bestiary of ad hoc databases: comma-, colon-, tab- and space-separated tables. Think of /etc/* or /var/log/*, or of columnar commands.

Shell scripts commonly, if unknowingly, compose five (of six) primitive relational-algebraic operations on these tables: union, difference, projection, selection and renaming:

  • cat acts like union;
  • sed and grep act like selection;
  • cut acts like projection;
  • awk can perform renaming; and
  • diff acts (almost) like difference.

Source: Relational shell programming, an article by Matt Might.