I have successfully exported lynis' output in terminal to a .txt file but when I tried to show it in my laravel modal, the colour codes become boxes of unknown characters (like when you send chinese text but its not supported by the device.
I have tried exporting it to .odt, .rtf and so on but the result is the same.
what I expected (the [done] is in green)
- Checking profiles... [ DONE ]
here's the actual result:
[2C- Checking profiles...[37C [ [1;32mDONE[0m ]
this is what I run in my ansible to get the output of lynis
./lynis audit system > /var/log/{{ inventory_hostname }}-lynis.txt
this is what I use in php to show the contents of the .txt
return nl2br(file_get_contents($path));
I checked the exported results in vim and it also shows
[2C- Checking profiles...[37C [ [1;32mDONE[0m ]
I know that .txt can't have coloured texts. so the question is which format should I use or how do I format it so that it can be shown with colours