<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.7.3" -->
<rss version="2.0">
	<channel>
		<title>How to colorize the output of grep</title>
		<description>Comments for How to colorize the output of grep at http://www.my-guides.net/en , comment 1 to 3 out of 3 comments</description>
		<link>http://www.my-guides.net/en</link>
		<lastBuildDate>Sat, 18 May 2013 23:57:25 +0100</lastBuildDate>
        <generator>FeedCreator 1.7.3</generator>
		<item>
			<title>...</title>
			<link>http://www.my-guides.net/en/guides/linux/how-to-colorize-the-output-of-grep#comment-2916</link>
			<description>I don't have an answer for your question TGM...

bjd I've fixed some missing spaces in your source. However still it doesn't seem to work correctly for me. - axel</description>
			<pubDate>Mon, 03 Dec 2012 16:29:31 +0100</pubDate>
		</item>
		<item>
			<title>Here's a utility to select color and attribute</title>
			<link>http://www.my-guides.net/en/guides/linux/how-to-colorize-the-output-of-grep#comment-2913</link>
			<description>#!/bin/sh

# colorsel
# make ANSI attribute/color string (the values only)  - bjd
# not all attributes are used here

TPUT=tput

${TPUT} clear
#echo -en &quot;33[H33[J&quot;

# attributes:
#  0 = all attributes off
#  1 = intensity 2 (bold)
#  2 = intensity 0 (half-bright)
#  4 = underline on
#  5 = blink on
#  7 = reverse on  
# 10 = G0/G1 charset
# 11 = 1st alternate font
# 12 = 2nd alternate font
# 21 = intensity 1 (normal, default)
# 22 = intensity 1 (normal, default)
# 24 = underline off
# 25 = blink off
# 27 = reverse off
# 38 = default fg, white underline
# 39 = default fg, underline off
# 49 = default bg

error()
{
echo -en &quot;nError: $1&quot;
ERROR=1
}

choose()
{
if [ ! &quot;$4&quot; = &quot;-1&quot; ]
then
PREV=$4
else
PREV=&quot;&quot;
fi
${TPUT} cup $1 0
echo -en &quot;Choose $3 number: $PREV&quot; &gt;&amp;2
${TPUT} cup $1 $2
read answer
if [ &quot;$answer&quot; = &quot;&quot; ]
then
answer=$4
fi
if [ ! &quot;$answer&quot; = &quot;-1&quot; ]
then
${TPUT} cup $1 $2
echo $answer&quot;   &quot;
fi
}

CHR=&quot;*&quot;
echo -e &quot;nttttBJ's colorsel %^)&quot;
echo -e &quot;nntttttBG&quot;
echo -e &quot;     black    red      green    yellow   blue     magenta  cyan     white&quot;
echo -e &quot;     40       41       42       43       44       45       46       47&quot;
for FG in 30 31 32 33 34 35 36 37
do
if [ $FG -eq 33 ]
then
echo -n &quot;F  $FG&quot;
elif [ $FG -eq 34 ]
then
echo -n &quot;G  $FG&quot;
else
echo -en &quot;   $FG&quot;
fi

for BG in 40 41 42 43 44 45 46 47
do
echo  -en &quot;[${BG};${FG}m${CHR}[m&quot;

echo  -en &quot;[1;${BG};${FG}m${CHR}[m&quot;
echo  -en &quot;[1;4;${BG};${FG}m${CHR}[m&quot;
echo  -en &quot;[1;4;7;${BG};${FG}m${CHR}[m&quot;
echo  -en &quot;[1;7;${BG};${FG}m${CHR}[m&quot;

echo  -en &quot;[2;${BG};${FG}m${CHR}[m&quot;
echo  -en &quot;[2;4;${BG};${FG}m${CHR}[m&quot;
echo  -en &quot;[2;4;7;${BG};${FG}m${CHR}[m&quot;
echo  -en &quot;[2;7;${BG};${FG}m${CHR}[m&quot;

#echo -en &quot;[4;${BG};${FG}m${CHR}[m&quot;
#echo -en &quot;[4;7;${BG};${FG}m${CHR}[m&quot;
done
echo
done
ATTR_NRS=&quot;012345678&quot;
echo -e &quot;     ${ATTR_NRS}${ATTR_NRS}${ATTR_NRS}${ATTR_NRS}${ATTR_NRS}${ATTR_NRS}${ATTR_NRS}${ATTR_NRS}&quot;
echo -e &quot;tttt       ATTR&quot;


BG=&quot;-1&quot;
FG=&quot;-1&quot;
AT=&quot;-1&quot;
while [ 1 = 1 ]
do
ERROR=0
${TPUT} cup 19 0
#${TPUT} ed
choose 18 26 &quot;background&quot; $BG
BG=$answer
choose 19 26 &quot;foreground&quot; $FG
FG=$answer
choose 20 26 &quot;attribute &quot; $AT
AT=$answer

if [ ! $BG = -1 ]
then
if [ $BG -lt 40 -o $BG -gt 47 ]
then
error &quot;background out of range (should be empty or [40-47])&quot;
fi
fi
if [ ! $FG = -1 ]
then
if [ $FG -lt 30 -o $FG -gt 37 ]
then
error &quot;foreground out of range (should be empty or [30-37])&quot;
fi
fi
if [ ! $AT = -1 ]
then
if [ $AT -gt 8 ]
then
error &quot;attribute choice out of range (should be empty or [0-8])&quot;
fi
fi

if [ $ERROR -eq 0 ]
then
${TPUT} ed
echo -n &quot;Combined string         : &quot;
SEP=&quot;;&quot;
if    [ &quot;$AT&quot; = &quot;-1&quot; ]; then STR=&quot;&quot;;SEP=&quot;&quot;;
elif  [ &quot;$AT&quot; = &quot;0&quot; ]; then STR=&quot;0&quot;;
elif  [ &quot;$AT&quot; = &quot;1&quot; ]; then STR=&quot;1&quot;;
elif  [ &quot;$AT&quot; = &quot;2&quot; ]; then STR=&quot;1;4&quot;;
elif  [ &quot;$AT&quot; = &quot;3&quot; ]; then STR=&quot;1;4;7&quot;;
elif  [ &quot;$AT&quot; = &quot;4&quot; ]; then STR=&quot;1;7&quot;;
elif  [ &quot;$AT&quot; = &quot;5&quot; ]; then STR=&quot;2&quot;;
elif  [ &quot;$AT&quot; = &quot;6&quot; ]; then STR=&quot;2;4&quot;;
elif  [ &quot;$AT&quot; = &quot;7&quot; ]; then STR=&quot;2;4;7&quot;;
elif  [ &quot;$AT&quot; = &quot;8&quot; ]; then STR=&quot;2;7&quot;;
#elif [ &quot;$AT&quot; = &quot;9&quot; ]; then #STR=&quot;4&quot;;
#elif [ &quot;$AT&quot; = &quot;A&quot; ]; then #STR=&quot;4;7&quot;;
fi

if [ ! &quot;$BG&quot; = &quot;-1&quot; ]
then
STR=&quot;${STR}${SEP}${BG}&quot;
SEP=&quot;;&quot;
fi

if [ ! &quot;$FG&quot; = &quot;-1&quot; ]
then
STR=&quot;${STR}${SEP}${FG}&quot;
fi

echo ${STR}&quot;          &quot;

if [ ! &quot;${STR}&quot; = &quot;&quot; ]
then
STR=&quot;33[${STR}m&quot;
fi

echo -e &quot;nnnIs ${STR}this33[m what you had in mind?&quot;
echo -e &quot;And then you could add a 5 attribute to make it 33[5m${STR}blink33[m...&quot;

echo -n &quot;Again? &quot;
read answer
if [ &quot;$answer&quot; = &quot;n&quot; -o &quot;$answer = &quot;N&quot; -o &quot;$answer = &quot;no&quot; ]
then
exit
fi
fi
done
 - bjd</description>
			<pubDate>Mon, 03 Dec 2012 08:21:07 +0100</pubDate>
		</item>
		<item>
			<title>A sincere question</title>
			<link>http://www.my-guides.net/en/guides/linux/how-to-colorize-the-output-of-grep#comment-2912</link>
			<description>Why does grep (and other tools) do this kind of thing by default yet (maybe via a build switch)? - TGM</description>
			<pubDate>Mon, 03 Dec 2012 04:23:09 +0100</pubDate>
		</item>
	</channel>
</rss>
