CMD Master
Back to Blog
Arnošt Havelka

Practical: Text Ops

Real-world scenario: Filtering logs and extracting data.

Start Interactive Lesson
Practical: Text Ops

Practical: Text Processing

In this scenario, we act as a system administrator analyzing a server log file. We need to find errors, count them, and suspect a specific user is causing trouble.

The Mission

You have a large server.log file. You need to:

  1. Find all "Error" entries.
  2. Count how many time "Timeout" occurred.
  3. Check if user "admin" logged in.

Step 1: Find all Errors

Use find to filter the log for lines containing "Error".

Command Prompt
C:\Users\User>find "Error" server.log

Step 2: Count Timeouts

Use find /c to count occurrences of "Timeout".

Command Prompt
C:\Users\User>find /c "Timeout" server.log

Step 3: Search for User Login

Use findstr to look for a specific pattern.

Command Prompt
C:\Users\User>findstr "Login.*admin" server.log

Step 4: Extract Errors to a separate file

Save your findings for a report.

Command Prompt
C:\Users\User>find "Error" server.log > error_report.txt

Knowledge Check

1 / 2

Which command would you use to simple count matching lines?

Up Next

Practical: Directory Ops

Real-world scenario: Setting up a project structure.