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.
Terminal - icon png.png Terminal & Files - icon.png


What you’ll learn

Info

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.

Example

Create a new file:

touch notes.md        # Mac / Linux
New-Item notes.md     # Windows PowerShell
Tip

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.

Example

Open a file using nano:

nano notes.md
Info

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.

Example

Show file contents:

cat notes.md
Example

View long files (scrollable):

less notes.md

Filtering Output with grep

grep lets you filter text output and show only what matches.

Example

Search for text inside a file:

grep "error" notes.md
Example

Filter command output using a pipe:

ls | grep ".md"
Tip

Think of grep as:
“Only show me lines that contain this.”


Typical File Workflow

Example

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?

Success

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