Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Run a bash for-loop on a stream

I’m using Git Bash for Windows. I want to find every folder named foo and open it in explorer with the command start.

for x in $(find . -name '*foo*' -type d 2> /dev/null); do
  start "$x"
done

I would like the folders to open as they are discovered, as opposed to all at once after the find command is complete. Note that start will open the folder and exit immediately.

How can I treat my find command as a stream and tell bash to run the loop after any new line is printed?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Just use the -exec primary.

find . -name '*foo*' -type d -exec start {} \;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading