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 3672780
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:39:04+00:00 2026-05-19T02:39:04+00:00

When I look for log files with an error message using grep error *log

  • 0

When I look for log files with an error message using grep error *log, it returns a list of logfiles

$grep error *log

Binary file out0080-2011.01.07-12.38.log matches
Binary file out0081-2011.01.07-12.38.log matches
Binary file out0082-2011.01.07-12.38.log matches
Binary file out0083-2011.01.07-12.38.log matches

However, these are text, not binary files.

I am not sure why these are considered binary, the first few lines contain the following non-error messages:

out0134
-catch_rsh /opt/gridengine/default/spool/compute-0-17/active_jobs/327708.1/pe_hostfile
compute-0-17

I would like to grep the contents of the returned files for an error message and return the names of the files with the message.

How can I grep the contents of the returned files, rather than this list of returned files, as happens with grep error *log | grep foo?

  • 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-05-19T02:39:05+00:00Added an answer on May 19, 2026 at 2:39 am

    Here’s the answer you might be looking for:

    grep -l foo $(grep -l error *.log)
    

    -l tells grep to print filenames only; that does the first grep, then substitutes the result into the next grep’s command. Alternatively, if you like xargs:

    grep -l error *.log | xargs grep -l foo
    

    which does the same thing, using xargs to call the second grep with the first grep’s results as arguments.

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

Sidebar

Related Questions

So my typical router log on the Cedar platform looks might look like 2012-03-22T18:26:34+00:00
I am trying to analyse the IIS log and would like to look at
look at this fiddle: http://jsfiddle.net/ugxNK/ I want that the first list element is in
I have a log file full of queries, and I only want to see
I have a situation wherein I want to send error and log messages to
Below is the related part from a QMGR log file about a WMQ channel
If you publish an ASP.NET app that has an error in the web.config file,
I have a log file containing the following data: Shortest path(2)::RV3280-RV0973C-RV2888C Shortest path(1)::RV3280-RV2502C Shortest
I was halfway of changing my code to print a Log message each time
Look at the function below. I want to pass a vector of factors and

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.