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

  • Home
  • SEARCH
  • 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 983699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:54:02+00:00 2026-05-16T04:54:02+00:00

I’m not sure if this is possible in one line (i.e., without writing a

  • 0

I’m not sure if this is possible in one line (i.e., without writing a script), but I want to run an ls | grep command and then for each result, pipe it to another command.

To be specific, I’ve got a directory full of images and I only want to view certain ones. I can filter the images I’m interested in with ls | grep -i <something>, which will return a list of matching files. Then for each file, I want to view it by passing it in to eog.

I’ve tried simply passing the results in to eog like so:

eog $(ls | grep -i <something>)

This doesn’t quite work as it will only open the first entry in the result list.

So, how can I execute eog FILENAME for each entry in the result list without having to bundle this operation into a script?

Edit: As suggested in the answers, I can use a for loop like so:

for i in 'ls | grep -i ...'; do eog $i; done

This works, but the loop waits to iterate until I close the currently opened eog instance.

Ideally I’d like for n instances of eog to open all at once, where n is the number of results returned from my ls | grep command. Is this possible?

Thanks everybody!

  • 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-16T04:54:03+00:00Added an answer on May 16, 2026 at 4:54 am

    Try looping over the results:

    for i in `ls | grep -i <something>`; do
        eog $i
    done
    

    Or you can one-line it:

    for i in `ls | grep -i <something>`; do eog $i; done
    

    Edit: If you want the eog instances to open in parallel, launch each in a new process with eog $i &. The updated one-liner would then read:

    for i in `ls | grep -i <something>`; do (eog $i &); done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.