AI Courses

Looking inside

Written by

in

Looking inside | Master AI Automation in 4 hours Master AI Automation in 4 hours Course About Ayush Modules Sample chapter Toolbox The Microcap Minute Classroom / Module 03: The Command Line / Chapter 4 Looking inside Watch first, then read. Same lesson, your pace. What you will learn – Reading files without opening any app – grep : searching text at machine speed – Pipes: why the terminal is more than a sum of its commands Reading cat notes.txt # print entire file head notes.txt # first 10 lines tail notes.txt # last 10 lines head -20 notes.txt # first 20 lines (-n works everywhere) Why read in a terminal when apps exist? Because these work on any text file instantly, logs, code, CSVs, config, with zero loading time, and because they can be chained (two minutes from now). Searching: grep grep finds lines containing a pattern across one or a million files: grep “error” server.log # show error lines grep -i “error” server.log # case-insensitive grep -n “error” server.log # with line numbers grep -r “TODO” ai-workspace # search every file in a tree That last form replaces twenty minutes of clicking through folders with half a second. When a friend says “somewhere in this project there’s a file mentioning the API key”, you are now the hero: grep -r “api_key” . The pipe: Unix’s best idea Watch closely: ls -l | head The vertical bar | connects programs: take the output of the left command and feed it as input to the right one. ls -l produces a long list; head cuts it to ten lines; combined: show me just the beginning of the long listing . Commands become Lego bricks: grep -i “error” server.log | sort | uniq # errors, sorted, deduplicated ls | wc -l # count files in this folder history | grep “git push” # which pushes did I run today? This is the deep idea of the terminal: small tools that do one thing well, combinable infinitely. You now possess the grammar to compose them. One more everyday tool in the same family, writing output somewhere: echo “bought milk” > list.txt # write into file (overwrites!) echo “also bread” >> list.txt # append to file > and >> redirect output into files, the terminal becoming your notepad. Try it yourself In ai-workspace : echo five lines about your day into day.txt using >> . Read it with cat , peek with head -2 . Then the finale: run history | tail -20 to see your own recent commands piped through tail . Finally, search your workspace: grep -r “milk” . , found yourself in your own filesystem. Save nothing; this fluency is the save. Key takeaways – cat / head / tail read anything instantly; no app needed. – grep searches text at machine speed; -i , -n , -r extend its reach. – Pipes | chain tools together, composition is the superpower. – > writes, >> appends: the terminal can write files too. Download the exercise sheet (PDF) Module workbook (PDF) โ† Prev: Making and moving things Next: Installing stuff without fear โ†’ Classroom / Module 03: The Command Line / Chapter 4 Looking inside What you will learn – Reading files without opening any app – grep : searching text at machine speed – Pipes: why the terminal is more than a sum of its commands Reading cat notes.txt # print entire file head notes.txt # first 10 lines tail notes.txt # last 10 lines head -20 notes.txt # first 20 lines (-n works everywhere) Why read in a terminal when apps exist? Because these work on any text file instantly, logs, code, CSVs, config, with zero loading time, and because they can be chained (two minutes from now). Searching: grep grep finds lines containing a pattern across one or a million files: grep “error” server.log # show error lines grep -i “error” server.log # case-insensitive grep -n “error” server.log # with line numbers grep -r “TODO” ai-workspace # search every file in a tree That last form replaces twenty minutes of clicking through folders with half a second. When a friend says “somewhere in this project there’s a file mentioning the API key”, you are now the hero: grep -r “api_key” . The pipe: Unix’s best ide

๐Ÿ“„ Download PDF

๐Ÿ“„ Download PDF