Linux, terminal and Git

Stage 3 of 8 · 8 lessons · ~2 weeks

Text tools

Search, filter and reshape text and files with the classic Unix tools and jq. Logs, config files, CSV exports and API responses all become things you can question from the terminal.

Start: Viewing files: cat, less, head and tail

Lessons· one lesson for each topic, in this order

  1. 1Viewing files: cat, less, head and tail
  2. 2Searching text with grep
  3. 3Finding files with find
  4. 4Sort, uniq, cut and wc
  5. 5Regular expressions basics
  6. 6Editing streams with sed
  7. 7Columns with awk
  8. 8JSON on the command line with jq

Do this

  • Follow a log live with `tail -f` while you trigger new lines.
  • Search a real project with `grep -rn` for a function name and for TODOs.
  • Find the five largest files under your home folder with find or du.
  • Produce a top 10 list from a log with `sort | uniq -c | sort -rn | head`.
  • Test three regular expressions on regex101 before using them with grep.
  • Replace a value across a file with sed, first previewing, then in place with Git as a backup.
  • Pull fields from an API response with curl and jq.

Start with· follow one of these

Practise

  • Test regular expressions on sample text with a plain explanation of each part

  • Middle levels need grep, sort, uniq and find to locate the next password

Keep handy

  • The official jq manual with examples for every filter

  • Quick examples for find, sed, awk and friends when you forget the syntax

Before moving on: A text file of 10 real questions you answered from a real log, CSV or JSON file (top error messages, largest files, busiest hour, active users from an API), each with the one-liner you used.

Tauseef's advice
Take real data you care about, such as your own shell history, a Git log or an export from a spreadsheet, and question it. These tools only stick when you use them for something. If a one-liner grows past two lines, that is fine; if it grows past five, write a script.

Mark this stage as not done?