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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:16:31+00:00 2026-06-07T23:16:31+00:00

I am successfully using find to create a list of all files in the

  • 0

I am successfully using find to create a list of all files in the current subdirectory, excluding those in the subdirectory “cache.” Here’s my first bit of code:

find . -wholename './cach*' -prune -o -print

I now wish to pipe this into a grep command. It seems like that should be simple:

find . -wholename './cach*' -prune -o -print | xargs grep -r -R -i "samson"

… but this is returning results that are mostly from the cache directory. I’ve tried removing the xargs reference, but that does what you’d expect, running the grep on text of the file names, rather than on the files themselves. My goal is to find “samson” in any files that aren’t cached content.

I’ll probably get around this issue by just using doubled greps in this instance, but I’m very curious about why this one-liner behaves this way. I’d love to hear thoughts on a way to modify it while still using these two commands (as there are speed advantages to doing it this way).

(This is in CentOS 5, btw.)

  • 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-07T23:16:33+00:00Added an answer on June 7, 2026 at 11:16 pm

    The wholename match may be the reason why it’s still including “cache” files. If you’re executing the find command in the directory that contains the “cache” folder, it should work. If not, try changing it to -name '*cache*' instead.

    Also, you do not need the -r or -R for your grep, that tells it to recurse through directories – but you’re testing individual files.

    You can update your command using the piped version, or a single-command:

    find . -name '*cache*' -prune -o -print0 | xargs -0 grep -il "samson"
    

    or

    find . -name '*cache*' -prune -o -exec grep -iq "samson" {} \; -print
    

    Note, the -l in the first command tells grep to “list the file” and not the line(s) that match. The -q in the second does the same; it tells grep to respond quietly so find will then just print the filename.

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

Sidebar

Related Questions

All these years i have been successfully using EnumServicesStatus in combination with OpenScManager (with
I'm using PhoneGap 1.4.1 to create an iPhone application. I can successfully perform the
I successfully created my first Entity Framework Code first project using SQL Server CE.
I am using ColdFusion 9. I can't find a means to successfully output a
I am successfully using zxing to scan codes, by calling the installed barcode reader's
I'm (almost) successfully using Node.js with Express and Redis to handle sessions. The problem
I'm successfully using assets pipeline for months. Now I would like to load some
I'm successfully using Node.js + Express + Everyauth ( https://github.com/abelmartin/Express-And-Everyauth/blob/master/app.js ) to login to
I've been successfully using Django's admin panel for internal users for a while but
Is anyone successfully using Expression Blend Preview for .NET 4 with the RC of

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.