June 15, 2026 · by Meegrow Labs

Terminal Commands for Reading & Writing Files: Level 3 Recap

You started Level 3 not knowing how to peek inside a file from the keyboard. Now you can open it, edit it, and even hunt for a single word buried deep inside it. That is a real jump.

Before we move on to Git, let’s pause and lock everything in, so it sticks.

The terminal commands for reading and writing files are simple: use cat, head and tail to read, echo with > and >> to write, and grep, the pipe | and wc to search and count. That is the whole toolkit, and each command does one small job.

What can you do now with the terminal?

By the end of Level 3, you can do three things to any text file on your computer, without ever opening an app:

  • Read a file’s contents.
  • Write text into a file.
  • Search and count what is inside it.

Think of it like a small toolbox. Each tool is plain and predictable. You don’t need all of them at once, you just pick the right one for the job.

Which terminal commands read files?

Three commands cover reading, and they differ only in how much they show you.

  • cat file.txt prints the whole file.
  • head file.txt shows the top few lines.
  • tail file.txt shows the bottom few lines.

So if you just want a quick look at a long log without scrolling forever, head or tail saves you time. Want the full thing? Reach for cat.

How do you write to a file from the terminal?

Writing comes down to one command and two little arrows. The echo command simply prints text, and the arrow decides where that text goes.

echo "hello" > notes.txt   # one arrow makes a new file
echo "world" >> notes.txt  # two arrows add to the end

Here is the difference to remember. One arrow > creates or overwrites the file. Two arrows >> add to it without erasing what is already there. Mix those up and you can wipe a file by accident, so it is worth saying out loud the first few times.

How do you search inside files?

Searching is where the terminal really starts to feel powerful. Three tools handle it.

  • grep finds lines that contain a word, like Ctrl-F for any file.
  • The pipe | chains commands, sending the output of one straight into the next.
  • wc counts lines, words and characters.

For example, to count how many error lines are in a log, you can chain them together:

grep "error" log.txt | wc -l

That reads as: find every line with the word “error”, then count those lines. You already know exactly what each piece does, which is the whole point.

Why do these terminal commands matter?

These small commands are the foundation everything else sits on. Once you can read, write, and search any file you meet, you can inspect what a program produced, fix a config by hand, or trace a bug through a log file.

Tools like Claude Code work the same way underneath, running commands like these on your behalf. Knowing the terminal commands for reading and writing files means you can actually follow along, check the work, and stay in control instead of just hoping it worked.

This is exactly the kind of foundation we build step by step in the free Zero to AI Hero course — one short lesson at a time, in plain language.

Key takeaways

  • Read: cat (whole file), head (top), tail (bottom).
  • Write: echo with > to create and >> to add.
  • Search: grep to find, | to chain, wc to count.
  • One arrow overwrites, two arrows append — remember the difference.
  • These terminal commands for reading and writing files are the base layer for Git, real coding, and AI tools.

Try it right now: open a terminal and type grep "error" log.txt. You knew exactly what that does — that is Level 3 locked in. Next up: why version control, and your first steps with Git, which keeps all this work safe.


🚀 Take the full free course: Zero to AI Hero — learn to build with AI from scratch. New lessons daily, in Hindi & English.

Meegrow Labs

We help India go from zero to AI hero — learn to use & build with AI from scratch, in Hindi & English. Start the free course →

Want to actually learn this?

151 free 2-minute lessons — from "what's a file?" to building with AI.

▶ Start the free course