[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How to preserve ansi color when piping (across platform)
From: |
Dennis Williamson |
Subject: |
Re: [Help-bash] How to preserve ansi color when piping (across platform)? |
Date: |
Sun, 24 May 2015 22:58:58 -0500 |
GNU ls has the --color=always option. What are you really trying to do?
BTW, the version of script on my linux system needs -c to run a command:
script -c 'ls -G /'
On Sun, May 24, 2015 at 9:42 PM, Peng Yu <address@hidden> wrote:
> Hi,
>
> The following example shows how to preserver ansi color when piping.
> But script is not compatible between mac and linux. Is there a way
> that works across platform?
>
>
> http://stackoverflow.com/questions/7641392/bash-command-preserve-color-when-piping
>
> ls -G /
> ls -G / | cat
> script -q /dev/null ls -G / | tr -d '\r' | cat
>
> # write output of script command to a variable
> var="$(script -q /dev/null ls -G / | tr -d '\r' | cat)"
> echo "$var"
>
> --
> Regards,
> Peng
>
>
--
Visit serverfault.com to get your system administration questions answered.