ansi2txt

Command-line tool that converts text containing ANSI control codes into plain ASCII text. It works as a filter, reading from stdin or a file, removing all ANSI codes, and sending the output to stdout.
This repo was inspired by kilobyte/colorized-logs.
Installation
APT (Ubuntu, Debian)
Click to expand
-
If you don't have it already, install the ca-certificates package
sudo apt install ca-certificates
-
Add gabe565 apt repository
echo 'deb [trusted=yes] https://apt.gabe565.com /' | sudo tee /etc/apt/sources.list.d/gabe565.list
-
Update apt repositories
sudo apt update
-
Install ansi2txt
sudo apt install ansi2txt
RPM (CentOS, RHEL)
Click to expand
-
If you don't have it already, install the ca-certificates package
sudo dnf install ca-certificates
-
Add gabe565 rpm repository to /etc/yum.repos.d/gabe565.repo
[gabe565]
name=gabe565
baseurl=https://rpm.gabe565.com
enabled=1
gpgcheck=0
-
Install ansi2txt
sudo dnf install ansi2txt
AUR (Arch Linux)
Click to expand
Install ansi2txt-bin with your AUR helper of choice.
Homebrew (macOS, Linux)
Click to expand
Install ansi2txt from gabe565/homebrew-tap:
brew install gabe565/tap/ansi2txt
Manual Installation
Click to expand
- Download and run the latest release binary for your system and architecture.
- Extract the binary and place it in the desired directory.
Usage
If ansi2txt is run with no arguments, it will read data from stdin, filter control codes, and write to stdout. A filename argument can also be provided to filter the file's contents to stdout.
Examples
- Read data from stdin:
ls --color=always | ansi2txt
- Read data from a file:
ansi2txt example.txt