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

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!

Terminal
C:\Users\Student>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.

Terminal
C:\Users\Student>echo Status: Success >> backup.log

Step 3: Check the Content

Use type to read the file content.

Terminal
C:\Users\Student>type backup.log

Step 4: Create a Config File

Creating a multiline file using multiple echo commands.

Terminal
C:\Users\Student>(echo debug=true && echo port=8080) > config.ini

Knowledge Check

1 / 3

Which operator OVERWRITES the file?

References

These documentation links provide authoritative details for the commands used in this article.

Up Next

Revision 1: DIR & ECHO

Practice what you've learned with DIR and ECHO challenges.