Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
4 added 8 characters in body
source | link

If you haven't GNU grep available, here is something more portable:

grepc()
{
  pattern=$1
  shift
  esc=$(printf "\033")
  sed 's"'"$pattern"'"'$esc'[32m&'$esc'[0m"g' "$@"
}

You can customize the color using one of these codes

30 30m black
31 31m red
32 32m green
33 33m yellow
34 34m blue
35 35m magenta
36 36m cyan
37 37m white

Using 77m instead of a color code will put the string in reverse video.

If you haven't GNU grep available, here is something more portable:

grepc()
{
  pattern=$1
  shift
  esc=$(printf "\033")
  sed 's"'"$pattern"'"'$esc'[32m&'$esc'[0m"g' "$@"
}

You can customize the color using one of these codes

30  black
31  red
32  green
33  yellow
34  blue
35  magenta
36  cyan
37  white

Using 7 instead of a color code will put the string in reverse video.

If you haven't GNU grep available, here is something more portable:

grepc()
{
  pattern=$1
  shift
  esc=$(printf "\033")
  sed 's"'"$pattern"'"'$esc'[32m&'$esc'[0m"g' "$@"
}

You can customize the color using one of these codes

30m black
31m red
32m green
33m yellow
34m blue
35m magenta
36m cyan
37m white

Using 7m instead of a color code will put the string in reverse video.

3 added 36 characters in body
source | link

If you haven't GNU grepgrep available, here is something more portable:

grepc()
{
  pattern=$1
  shift
  esc=$(printf "\033")
  sed 's"'"$pattern"'"^[[32m&^[[0m"g''s"'"$pattern"'"'$esc'[32m&'$esc'[0m"g' "$@"
}

You can customize the color using one of these codes

30  black
31  red
32  green
33  yellow
34  blue
35  magenta
36  cyan
37  white

Using 7 instead of a color code will put the string in reverse video.

If you haven't GNU grep available, here is something more portable:

grepc()
{
  pattern=$1
  shift
  sed 's"'"$pattern"'"^[[32m&^[[0m"g' "$@"
}

You can customize the color using one of these codes

30  black
31  red
32  green
33  yellow
34  blue
35  magenta
36  cyan
37  white

Using 7 instead of a color code will put the string in reverse video.

If you haven't GNU grep available, here is something more portable:

grepc()
{
  pattern=$1
  shift
  esc=$(printf "\033")
  sed 's"'"$pattern"'"'$esc'[32m&'$esc'[0m"g' "$@"
}

You can customize the color using one of these codes

30  black
31  red
32  green
33  yellow
34  blue
35  magenta
36  cyan
37  white

Using 7 instead of a color code will put the string in reverse video.

2 added 244 characters in body
source | link

If you haven't GNU grep available, here is something more portable:

grepc()
{
  pattern=$1
  shift
  sed 's"'"$pattern"'"^[[32m&^[[0m"g' "$@"
}

You can customize the color using one of these codes

30  black
31  red
32  green
33  yellow
34  blue
35  magenta
36  cyan
37  white

Using 7 instead of a color code will put the string in reverse video.

If you haven't GNU grep available, here is something more portable:

grepc()
{
  pattern=$1
  shift
  sed 's"'"$pattern"'"^[[32m&^[[0m"g' "$@"
}

If you haven't GNU grep available, here is something more portable:

grepc()
{
  pattern=$1
  shift
  sed 's"'"$pattern"'"^[[32m&^[[0m"g' "$@"
}

You can customize the color using one of these codes

30  black
31  red
32  green
33  yellow
34  blue
35  magenta
36  cyan
37  white

Using 7 instead of a color code will put the string in reverse video.

1
source | link