0

I tried the following command to capture the output of a command (grep as an example) with color. But the result is shown as ^[[01;31m^[[Ka^[[m^[[K.

grep --color=always a <<< a | 
    a2ps -=book -B -q --medium=A4dj --borders=no -o out1.ps &&
    gs \
    -sDEVICE=png16m           \
    -dNOPAUSE -dBATCH -dSAFER \
    -dTextAlphaBits=4 -q      \
    -r300x300                 \
    -sOutputFile=out2.png out1.ps

Is there a way to capture the color in the image? Thanks.

KenS
  • 30,202
  • 3
  • 34
  • 51
user1424739
  • 11,937
  • 17
  • 63
  • 152
  • [May](https://unix.stackexchange.com/questions/70450/can-groff-create-a-ps-file-with-interpreted-ansi-escape-characters) [be](https://superuser.com/questions/552657/how-to-convert-ansi-colored-text-to-pdf) [related](https://stackoverflow.com/questions/245121/a-library-to-convert-ansi-escapes-terminal-formatting-color-codes-to-html). – user202729 Mar 18 '18 at 13:46
  • It's related (and closed). There are various ways to do what's asked, but "Is there a way" makes the question non-topical. – Thomas Dickey Mar 18 '18 at 14:45

0 Answers0