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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:17:42+00:00 2026-06-16T12:17:42+00:00

I have a directory structure containing some files. I’m trying to find the names

  • 0

I have a directory structure containing some files. I’m trying to find the names of top directories that do contain a file with specific string in it.

I’ve got this:

grep -r abcdefg . | grep commit_id | sed -r 's/\.\/(.+)\/.*/\1/';

Which returns something like:

topDir1
topDir2
topDir3

I would like to be able to take this output and somehow feed it into this command:

ls -t | grep -e topDir1 -e topDir2 -e topDir3

which would returned the output filtered by the first command and ordered by modification date.

I’m hoping for a one liner. Or maybe there is a better way of doing it?

  • 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-16T12:17:44+00:00Added an answer on June 16, 2026 at 12:17 pm

    This should work as long as none of the directory names contain whitespace or wildcard characters:

    ls -td $(grep -r abcdefg . | grep commit_id | dirname)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a directory structure of directories and files that I want to render
I have a highly structured hierarchical directory containing multiple files that need to be
I have some directories containing test data, typically over 200,000 small (~4k) files per
I have a public/ directory that I have set up as containing static files
I have a directory structure containing a bunch of config files for an application.
I'm trying to create a directory structure of years containing sub-directories representing months, ie.
I have a directory structure that looks like this: /a/f.xml /b/f.xml /c/f.xml /d/f.xml What
I have a directory structure as follows Client_Site/ some_folder1/ some_folder2/ some_folder3/ Lots of files
How can I serve some static content in liferay? I have a directory structure
I have a directory structure (multiple levels deep) of resources, that I would like

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.