In any case, the use of
ls here is not only unnecessary, but also
wrong. The proper way to run the command is with a simple
globbing pattern.
If you need to avoid the max argument limit, you can do store the files in an array first, and loop over them.
Code:
rpmarray=( *.rpm )
for (( i=0; i<${#rpmarray[*]}; i+=25 )); do
rpm -i ${rpmarray[@]:i:25}"
done
This will loop over all the files, processing 25 at a time.
I ran a quick test of the above on the entire content of my
/etc directory, and it had no problems.
Do note though that the above relies on several bash extensions, and won't work properly in a posix-only shell. You'll have to use
find and/or
xargs if that's necessary.
See here for more on shell limits:
I'm getting "Argument list too long". How can I process a large list in chunks?
http://mywiki.wooledge.org/BashFAQ/095