command explanation

can anyone please tell me what does this expression means , i am under probation and need some explanation :slight_smile:

$AUDIT_DIR -type f -mtime +$AUDIT_EXPIRE \ -exec rm {} > /dev/null 2>&1 \;
 
 
AUDIT_DIR="/var/log/"
AUDIT_EXPIRE='30'

command will find and remove the files which are older than 30 days in /var/log path

thanks a lot :slight_smile:

---------- Post updated at 05:28 PM ---------- Previous update was at 05:12 PM ----------
is the right format could be written like that:

/usr/bin/find . $AUDIT_DIR -type f -mtime +$AUDIT_EXPIRE | -exec rm {} > /dev/null 2>&1

or

/usr/bin/find . $AUDIT_DIR -type f -mtime +$AUDIT_EXPIRE \ -exec rm {} > /dev/null 2>&1 \

please can i have explanation for the one that is true ? :blush: sorry for tking of ur time

Neither | nor \ make much sense there. I don't think it has any purpose at all at present, and would prevent it from working.

I suspect it was originally this:

/usr/bin/find . $AUDIT_DIR -type f -mtime +$AUDIT_EXPIRE \
        -exec rm {} > /dev/null 2>&1

The backslash at the end of the first line makes the shell interpret both as one longer line. This is often used to wrap long lines of code so they're not wider than your editor.

thanks a lot corona688 for the tips :slight_smile: , it was really helpful :slight_smile:

regards