Hello ,

I got this script that read directories, create a zip file with the date of the file, and put all files in that date inside Zip:

dir=/iscsi/webserver231/; for subdir in "$dir"/*/; do find "$subdir" -type f -name 'ex??????.log' -exec bash -c 'for f; do f=${f##*/ex}; echo "${f%??.log}"; done' - {} + | sort -u | while read date; do find "$subdir" -type f -name "ex${date}??.log" -exec zip -m "${subdir}/${date}.zip" {} +; done; done

This script is made to logfile name "exyymmdd.log" , now i got "www.xxxxxxx.pt-access_log.09-03-30" and the script dont work, thats logic :)
I tried to modify it but with no success , pls help


Best regards

Well you could read the intro guides on how to post code, perhaps format the script so it's easier to read.

As opposed to one massive 1-liner which no-one wants to look at at all.

dir=/iscsi/webserver231/; for subdir in "$dir"/*/; do find "$subdir" -type f -name 'ex??????.log' -exec bash -c 'for f; do f=${f##*/ex}; echo "${f%??.log}"; done' - {} + | sort -u | while read date; do find "$subdir" -type f -name "ex${date}??.log" -exec zip -m "${subdir}/${date}.zip" {} +; done; done

Is this correct?
tks in advance

dir=/iscsi/webserver231/; for subdir in "$dir"/*/; do find "$subdir" -type f -name 'ex??????.log' -exec bash -c 'for f; do f=${f##*/ex}; echo "${f%??.log}"; done' - {} + | sort -u | while read date; do find "$subdir" -type f -name "ex${date}??.log" -exec zip -m "${subdir}/${date}.zip" {} +; done; done

Each of your -exec clauses needs to be terminated with an escaped semi-colon, as in:

find / -name \*JPG -exec chmod 644 {} \; -print

At least the shell and possibly find() are having trouble determining where the find's -exec command ends.

Hello,

The script is working without problems.
What i need is to adapt to new logfile name "www.xxxxxxx.pt-access_log.09-03-30" to this script.

Help :)

Is solved.
I could post the new script, but...... every problem i post here it dont get solved.
And i get answers like "So change the name in the find command." LOOOL

This question has already been answered. Start a new discussion instead.