CMD Master
Back to Blog
Arnošt Havelka

Practical: Echo Files

Real-world scenario: Creating logs and config files.

Start Interactive Lesson
Practical: Echo Files

Practical: Echo & Redirection

The echo command isn't just for printing text to the screen. Combined with redirection operators (> and >>), it becomes a powerful tool for creating files, writing logs, and generating configuration files on the fly.

The Mission

You are automated a backup script. You need to creating a log file, adding a timestamp entry to it, and creating a simple configuration file.

Step 1: Create a New Log File

We use > to write output to a file. Warning: This overwrites the file if it exists!

Command Prompt
C:\Users\User>echo Backup Started > backup.log

Step 2: Append to the Log

We use >> to add lines to the end of the file without erasing previous content.

Command Prompt
C:\Users\User>echo Status: Success >> backup.log

Step 3: Check the Content

Use type to read the file content.

Command Prompt
C:\Users\User>type backup.log

Step 4: Create a Config File

Creating a multiline file using multiple echo commands.

Command Prompt
C:\Users\User>(echo debug=true && echo port=8080) > config.ini

Knowledge Check

1 / 3

Which operator OVERWRITES the file?

Up Next

Tree Command

Visualize directory structures graphically.