How to open multiple files from `find` output?
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?
I think that in this case you could use
find ./ -name *.foo | xargs gedit
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
.
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.