Your full code is:
rm -f /tmp/temp.files
ls -1 /var/log/processing/*.log | xargs -n1 basename > /tmp/temp.files
cat /tmp/temp.files | sed -r "s~(.*)-[0-9]{4}(-[0-9]{2})+\.log~cat /var/log/processing/\1* >> /var/log/processing/\1$(date +"-%Y-%m-%d-%H-%M").log~" | uniq | sh
cd /var/log/processing
xargs rm -rf < /tmp/temp.files
rm -f /tmp/temp.files
But the problem lies on the ls -1 /var/log/processing/*.log
part, so I am skipping the rest.
The expansion done by /var/log/processing/*.log
gives so many results that ls
itself cannot handle all of them and hence prints the "Argument list too long" message.
You can use a find
statement like this:
find /var/log/processing -name "*.log" -exec basename {} \; > /tmp/temp.files
See I am not using ls parsing (read interesting Why you shouldn't parse the output of ls).