Skip to content

Instantly share code, notes, and snippets.

@stevenh512
stevenh512 / stripcolor
Created March 30, 2012 02:22
Strip color codes from Rails logs
#!/bin/sh
# Strip color codes from Rails logs
# Examples:
# stripcolor test.log > test.log.nocolor # Save a copy of the log without color
# stripcolor test.log | gist # Gist the log
# stripcolor test.log | pbcopy # Copy the log to the clipboard in OSX
# stripcolor test.log | xclip -selection clipboard # Copy log to clipboard in Linux
cat "$@" | sed -r "s/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g"