Last active
October 2, 2015 14:28
-
-
Save davidallsopp/5a5f199a0e4a843d7982 to your computer and use it in GitHub Desktop.
Colouring a text file to highlight spaces, tabs, etc. See also cat -A
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/bash | |
RED=`echo -e '\033[41m\033[37m'` | |
BLUE=`echo -e '\033[44m\033[37m'` | |
NORMAL=`echo -e '\033[0m'` | |
cat "$1" | sed -e s/\ /${BLUE}\ ${NORMAL}/g | sed -e s/$'\t'/${RED}\ \ \ \ ${NORMAL}/g |
Solved: pipe the output to "less -R", which preserves the colour escape sequences
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unfortunately doesn't play well with "less" (shows control chars) or "more" (shows blue spaces wrapping round entire lines, in some cases)