Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8774871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:40:29+00:00 2026-06-13T18:40:29+00:00

I would like to do a grep to dig through my code hierarchy and

  • 0

I would like to do a grep to dig through my code hierarchy and look for the term “x”, but color the results and exclude annoying terms. Right now I do:

grep -Rn --color x * | grep -v -e html -e svn -e test -e doc -e y

The problem is that this loses the matching color because of the pipe. Is there anyway to make this one statement so that the coloring isn’t lost?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:40:29+00:00Added an answer on June 13, 2026 at 6:40 pm

    Specify --color=always to preserve color formatting through pipes:

    grep --color=always x * | grep -v -e html -e svn -e test -e doc -e y
    

    And later on if you happen to need to pipe the result into a file and need to remove the escape characters that format color, here’s a nifty sed script you can pipe your results through to remove the escape charaters:

    sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" 
    

    (Note that you need -E option instead of -r for OS X)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to grep something like ==> *.sh <== . But it doesn't
Would like someone to take a look at my script and tell me where
Would like to know the c# code to actually retrieve the IP type: Static
I have this file call helloworld.txt: starthelloworld_some_text.jpgend starthelloworld_different_text.jpgend starthelloworld_another_different_one.jpgend and I would like Grep
I would like to have the echo command executed when cat /etc/passwd | grep
I think I have this right but I would like someone to verify that.
<tr>$ <td nowrap valign=top class=table_1row><a name=d071301 id=d071301></a>13-Jul-2011</td>$ i would like to match tr>$ grep
I would like to update grep on my Mac to a more recent version
I would like to call the following bash command in MATLAB: grep Up to
Sometimes I am reading some code and would like to find the definition for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.