From a63343a0941fb3f643eaa4dbcc4e61406c46c644 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 4 Jul 2018 11:50:15 -0400 Subject: [PATCH] Check in uncolor --- uncolor | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 uncolor diff --git a/uncolor b/uncolor new file mode 100755 index 0000000..96081bc --- /dev/null +++ b/uncolor @@ -0,0 +1,11 @@ +#!/usr/bin/env perl +## uncolor ? remove terminal escape sequences such as color changes +## Source: https://unix.stackexchange.com/questions/14684/removing-control-chars-including-console-codes-colours-from-script-output by Gilles +while (<>) { + s/ \e[ #%()*+\-.\/]. | + \e\[ [ -?]* [@-~] | # CSI ... Cmd + \e\] .*? (?:\e\\|[\a\x9c]) | # OSC ... (ST|BEL) + \e[P^_] .*? (?:\e\\|\x9c) | # (DCS|PM|APC) ... ST + \e. //xg; + print; +} -- 2.25.1