DEV Community

Bobo
Bobo

Posted on

text-processor: Batch Find, Replace, Extract, and Count Text Files

text-processor: Batch Find, Replace, Extract, and Count Text Files

Working with text files at scale? Whether it's log analysis, code refactoring, or content migration — text-processor handles it from the terminal.

Installation

npm install -g text-processor-pro
Enter fullscreen mode Exit fullscreen mode

Commands

Find and Replace

text-processor-pro replace *.txt "old_text" "new_text"
Enter fullscreen mode Exit fullscreen mode

Extract Lines Matching Pattern

text-processor-pro extract logs/*.log "ERROR" -o errors.txt
Enter fullscreen mode Exit fullscreen mode

Count Words and Lines

text-processor-pro count *.md --words --lines
# Total files: 12
# Total words: 15,234
# Total lines: 1,892
Enter fullscreen mode Exit fullscreen mode

Format Text

text-processor-pro format input.txt --uppercase -o output.txt
Enter fullscreen mode Exit fullscreen mode

Use Cases

  • Developers refactoring code across multiple files
  • Writers doing bulk content updates
  • Data analysts preprocessing text datasets
  • DevOps parsing and filtering log files

Example: Analyze Server Logs

# Find all 500 errors in last week's logs
text-processor-pro extract /var/log/*.log "HTTP/1.1 500" -o errors.txt
# Count unique error types
text-processor-pro count errors.txt --lines
# Replace sensitive data
text-processor-pro replace *.log "<password>" "[REDACTED]"
Enter fullscreen mode Exit fullscreen mode

Links

💻 GitHub: github.com/lb1192176991-lab/text-processor-pro

🌐 Visit us: https://www.tucaowall.vip/


This is part of a toolkit family — check out csv-toolkit, json-tidy, pdf-toolkit, and more!

☁️ Get free DigitalOcean credit: https://m.do.co/c/fc5cb7b29a0d

Top comments (0)