Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know I can open multiple files found in a dir like so:

find -name *.foo -xargs <command> {} \;

This works, but when trying to open a bunch of textfiles in gedit at the same time, it opens them successively (when one files is closed, the next one is opened).

I would like to open all of those files at the same time. How can I achieve this?

share|improve this question
up vote 10 down vote accepted

To act on multiple files at once with find, use + instead of \;:

find . -name '*.foo' -exec gedit {} +

With zsh, or with bash ≥4 if you put shopt -s globstar in your ~/.bashrc, you can use **/ to recurse into subdirectories:

gedit **/*.foo

Zsh also has many glob qualifiers which can replace most uses of find.

share|improve this answer
could somebody suggest how to run it on Mac OS X? – andi Nov 1 '13 at 1:57
@andi solved by myself. But if someone propose someting shorter, or forcing SublimeText to open in seperate tabs, rather than windows, it will be much apriciated. – andi Nov 1 '13 at 2:06
@andi This is an issue with SublimeText, you should ask it as a separate thread. – Gilles Nov 1 '13 at 2:47
anyway I think it is about exact bash format, because if I run for example open -a SublimeText admin.py forms.py it opens in one window with two tabs. – andi Nov 1 '13 at 2:53

I think that in this case you could use

find ./ -name \*.foo | xargs gedit
share|improve this answer
This won't work if the file name contains special characters (whitespace or \'"), because xargs requires its input to be quoted in a way that find doesn't produce. Either use find … -print0 | xargs -0 …, or use the simpler find … -exec … {} +. – Gilles Nov 28 '10 at 15:34
Also, though it doesn't apply in this case, -print0 | xargs -0 has the problem that stdin has been gobbled up, and is no longer attached to the terminal. A problem if you're trying to use a text-mode editor. – derobert Dec 14 '12 at 16:59

On Mac OS X bash you can run something like:

for file in $(find . -name "*.py"); do open -a SublimeText $file; done. 

One drawback is that it opens in new window of Sublime instead of using new tab.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.