Terminal & Files - Basics
Working with Files in the Terminal
This section focuses on creating, editing, reading, and filtering files
directly from the command line.. without leaving the terminal.
What you’ll learn
By the end of this section, you will be able to:
- Create files and folders
- Edit files using a terminal-based editor
- View file contents
- Filter output using
grep
Creating Files
Files can be created directly from the terminal.
Create a new file:
touch notes.md # Mac / Linux
New-Item notes.md # Windows PowerShell
If the file already exists, it will not be overwritten.
Editing Files in the Terminal
You don’t need a graphical editor to change files.
Files can be edited directly from the command line.
Open a file using nano:
nano notes.md
nano is beginner-friendly, but not guaranteed on all systems.
If nano is unavailable:
- Mac / Linux:
vi notes.md - Windows PowerShell:
notepad notes.md
These editors are launched from the terminal, even if they look different.
Viewing File Contents
Sometimes you only want to read a file.
Show file contents:
cat notes.md
View long files (scrollable):
less notes.md
lessFiltering Output with grep
greplets you filter text output and show only what matches.
Search for text inside a file:
grep "error" notes.md
Filter command output using a pipe:
ls | grep ".md"
Think of grep as:
“Only show me lines that contain this.”
Typical File Workflow
A common workflow might look like this:
touch notes.md
nano notes.md
cat notes.md
ls | grep ".md"
Each step builds on the previous one.
Now what?
You can now:
- Work with files without leaving the terminal
- Inspect and search text efficiently
- Use tools that appear everywhere in development
These skills are used constantly when working with code, logs, and servers.
Finished
Back to Overview: Developer Fundamentals