From: Alyssa Rosenzweig Date: Wed, 4 Jul 2018 15:50:15 +0000 (-0400) Subject: Check in uncolor X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a63343a0941fb3f643eaa4dbcc4e61406c46c644;p=libremanage.git Check in 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; +}