Home
> bash, Linux > Bash oneliner HOWTO to remove all the logs but from the last three days in case you face the “Argument list too long” issue
Bash oneliner HOWTO to remove all the logs but from the last three days in case you face the “Argument list too long” issue
# we assume the target directory is /var/spool/bsms/main/errors/
cd /var/spool/bsms/main/errors/; ls -lrt | egrep ".sql$" | egrep -v "$(date +"%Y-%m-%d")|$(date -d '1 day ago' +"%Y-%m-%d")|$(date -d '2 day ago' +"%Y-%m-%d")" | awk '{print$8}' | xargs --no-run-if-empty -icrap rm -f crap
Slackware4Life
Categories: bash, Linux
bash, Linux bash, logs clean up, Slackware
I think you could do the bash oneliner in awk but you would probably need to generate some intermediate files and end with a cleanup. Give me until February
yep I can , but it will be longer
cheers