Skip to main content

A Python CLI for common text processing tasks

Project description

txtool

A fast, colorful Python CLI for common text processing tasks — search, replace, filter, and stats — across single files, globs, or entire directories.

Installation

pip install txtlvit

Then use it as:

txtool --help

Commands

txtool search — grep-style search

txtool search "TODO" "**/*.py"           # regex search across all .py files
txtool search "error" app.log -n         # show line numbers
txtool search -i "warning" logs/*.log    # case-insensitive
txtool search --no-regex "fo+" file.txt  # literal string (not regex)
txtool search "def " src/ -n --no-color  # search entire directory
Flag Description
--regex / --no-regex Regex mode (default: on)
-i, --ignore-case Case-insensitive matching
-n, --line-numbers Show line numbers in output
--color / --no-color Colorize matched text

txtool replace — find & replace

txtool replace "foo" "bar" file.txt              # print result to stdout
txtool replace "foo" "bar" *.txt --in-place      # edit files in place
txtool replace "foo" "bar" file.txt --dry-run    # preview changes only
txtool replace -i "FOO" "bar" file.txt           # case-insensitive
txtool replace "v\d+" "v2" --no-regex file.txt   # literal replace
Flag Description
--regex / --no-regex Regex mode (default: on)
-i, --ignore-case Case-insensitive matching
--in-place Write changes back to file
--dry-run Show diff without writing

txtool filter — keep or remove lines

txtool filter "ERROR" app.log             # keep only ERROR lines
txtool filter -v "DEBUG" app.log          # remove DEBUG lines (invert)
txtool filter -i "warning" logs/*.log     # case-insensitive filter
txtool filter "^#" config.txt -v          # strip comment lines
Flag Description
-v, --invert Exclude matching lines instead
--regex / --no-regex Regex mode (default: on)
-i, --ignore-case Case-insensitive matching

txtool stats — line, word, char counts + top words

txtool stats file.txt                        # table output (default)
txtool stats *.txt --format plain            # plain text
txtool stats report.txt --format json        # JSON output
txtool stats notes.txt --top 5               # show top 5 words
Flag Description
--top N Number of top words to show (default: 10)
--format Output format: table, json, or plain

File Input

All commands accept any combination of:

Input Example
Single file file.txt
Glob pattern logs/*.log, **/*.py
Directory src/ (recurses all text files)

Binary files are automatically detected and skipped.


Quick Reference

txtool search  <pattern> <files...>              Search for pattern
txtool replace <pattern> <replacement> <files...> Find and replace
txtool filter  <pattern> <files...>              Filter lines by pattern
txtool stats   <files...>                        Show file statistics

Run txtool <command> --help for full options on any command.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

txtlvit-0.2.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

txtlvit-0.2.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file txtlvit-0.2.0.tar.gz.

File metadata

  • Download URL: txtlvit-0.2.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for txtlvit-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7f8184f2cc3f323904077212b80f05477d62b419083bbaa237ccf7f6356b6ca3
MD5 dabe693ea7d6ba4a29e84463f5a2f860
BLAKE2b-256 1822a84b32bd6af2e61f6d4e17a960cae473f985779a52888997674a24d95955

See more details on using hashes here.

File details

Details for the file txtlvit-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: txtlvit-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for txtlvit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d71c201770e4303240e1f21bbd2d799af2eb02c13dc0db919b567ab183a4005
MD5 294ce965cb2590d6a58a6890b1466a63
BLAKE2b-256 01571c5d5cf85f9656b79ea1f3b3730ffb6c7ded3b4b2c69d68c437c6263729d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page