Created
March 30, 2012 02:22
-
-
Save stevenh512/2245881 to your computer and use it in GitHub Desktop.
Strip color codes from Rails logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another useful use of this script is in a pipe: