Skip to content

Instantly share code, notes, and snippets.

@welmends
Created September 14, 2023 19:41
Show Gist options
  • Save welmends/ed3d1eabdaba4611a8a5abaceb5ee6fd to your computer and use it in GitHub Desktop.
Save welmends/ed3d1eabdaba4611a8a5abaceb5ee6fd to your computer and use it in GitHub Desktop.
Solving a formatting problem while using tee

Problem

Sometimes when we use | tee output.txt to obtain the logs of a command, we obtain unformatted logs due to the colors used by libraries such as logger

Solution

In order to fix this, you can use the sed tool to remove color escape sequences from the output.txt output file. You can do this with the following command:
cat output.txt | sed "s/\x1B\[[0-9;]*[mK]//g" > formatted_output.tx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment