Bash script to move spammy mails
I am trying to write bash script wich can cleanup my whoole server from spam emails that already are present in my client's folders. I would need this script to do,
Check recursively directory /var/qmail/mailnames/* for array of keywords if files with keyword has been found go two levels up to and move files there. I have started to write something like this, but it will not work as i need. First thing is that i get Argument list too log. Code:
grep -lir 'discount' /var/qmail/mailanmes/* | xargs mv -t /var/qmail/ |
Code:
man xargs |
I could not sort it out. It was not problem of an -n parameter. Script was working if there was small amount of files, but wheen it had 80k files in directory it just wasn't doing anything.
|
The '*' gets expanded by the shell and hits a size limit.
Consider looping eg using 'for file in $(find var/qmail/mailanmes/ -type f) ... If speed is really a concern, think about multiple jobs for files starting with different chars and/or use a faster lang like Perl. |
what about:
grep -lir 'discount' /var/qmail/mailanmes | xargs mv -t /var/qmail/ |
All times are GMT -5. The time now is 08:29 AM. |