Printing lynis reports

Support for security such as Firewalls and securing linux
Post Reply
MartinR
Posts: 714
Joined: 2015/05/11 07:53:27
Location: UK

Printing lynis reports

Post by MartinR » 2019/03/03 20:05:01

I'm generating lynis reports for some of my machines, but they have embedded escape codes which display nicely, but are seriously messing up the printer. I know there's a tool to convert such embedded layout codes to simple text, but I've been looking all day and not found it! Can anyone help?

Typical printed line:
[2C- Checking /proc/meminfo[35C [ FOUND ]

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: Printing lynis reports

Post by avij » 2019/03/03 20:48:34

In some cases the program being run is smart enough to stop emitting such escape codes if the output is redirected or piped somewhere else. See if yourcommand | cat makes a difference.

https://superuser.com/questions/380772/ ... ext-stream says you could also use sed: sed 's/\x1b\[[0-9;]*m//g' (although sed 's/\x1b\[[0-9;]*[Cm]//g' may work better for you, YMMV).

MartinR
Posts: 714
Joined: 2015/05/11 07:53:27
Location: UK

Re: Printing lynis reports

Post by MartinR » 2019/03/03 22:20:52

Thanks avij, the "cat" trick didn't work, but the second sed menu did. It has stripped out the escape sequence spacing, but of course I've lost the alignment. I'm sure I used to do something at work that achieved this, but I think it was part of the man(1) output that pointed me there, and man has changed out of all recognition from CentOS5 to CentOS7. IT was some command line "col", but I've not found anything that works. Perhaps I feel an AWK script coming on!

Again, thanks,
Martin

Post Reply