Making script logs clean

There are a lot of ways to clean up script logs either using macros in vim, sed one-liners or probably stand alone tools but I’ve found the easiest way is a simple function and alias within bash.

Add the following to your .bashrc file

function __sc {
        cat $1 | perl -pe 's/e([^[]]|[.*?[a-zA-Z]|].*?a)//g' | col -b > $1-processed

alias script_clean="__sc"

source the .bashrc and now you can execute $ script_clean scriptlog.log and it will output scriptlog.log-processed so its nice and clean without all those pesky control characters.