With GNU xargs
and a shell with support for process substitution
xargs -r -0 -P4 -n1 -a <(printf '%s\0' myfile*) mycommand
Would run up to 4 mycommand
s in parallel.
If mycommand
doesn't use its stdin, you can also do:
printf '%s\0' myfile* | xargs -r -0 -P4 -n1 mycommand
Which would also work with the xargs
of modern BSDs.
For a recursive search for myfile*
files, replace the printf
command with:
find . -name 'myfile*' -type f -print0
(-type f
is for regular-files only. For a glob-equivalent, you need zsh
and its printf '%s\0' myfile*(.)
).
find . -name "*xls*" -exec ls -l {} \;
. In your case:find . -name "*xls*" -exec mycommand {} \;
. Although find searches for files recursively you can limitfind
not to search in all sub directories. – mnille Feb 25 '16 at 11:32