You didn't say, but I assume this is where the problem occurs:
ls -tr $FROM_DIRECTORY/MSCERC*.Z|head -2500 |
xargs -i sh -c "mv {} $DESTINATION_DIRECTORY"
(You can verify it by adding "set -x" to the top of your script.)
The problem is that the kernel has a fixed maximum size of the total length of the command line given to a new process, and your exceeding that in the ls
command. You can work around it by not using globbing and instead using grep
:
ls -tr $FROM_DIRECTORY/ | grep '/MSCERC*.Z$' |head -2500 |
xargs -i sh -c "mv {} $DESTINATION_DIRECTORY"
(grep
uses regular expressions instead of globs, so the pattern looks a little bit different.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…