meaning

Can you please tell me the meaning of this

find /backup/logs/ -name daily_backup* -mtime +21 -exec rm -f {} ;


?

find /backup/logs/daily_backup* -mtime +5 -exec rm -f {} \;

?

find /backup/logs/daily_backup* -mtime +5 -delete;

?
jcob_lAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

farzanjCommented:
find /backup/logs/ -name daily_backup* -mtime +21 -exec rm -f {} ;

Find files in  /backup/logs/ directory with name daily_backup* (any characters or nothing after backup) that are more that 21 days old and remove them.
This command should have \; at the end or "{}" in quotations


find /backup/logs/daily_backup* -mtime +5 -exec rm -f {} \;
Find files in folders similar to /backup/logs/daily_backup* (anything after backup) that are more than 5 days old and remove them


find /backup/logs/daily_backup* -mtime +5 -delete;
Again find files more that 5 days old and delete them.

NOTE: mtime takes file's last modified time
* would mean 0 or more characters except for / that would mean next item in the path

For more examples, consult
http://www.cyberciti.biz/faq/howto-find-delete-empty-directories-files-in-unix-linux/
0
TintinCommented:
find /backup/logs/ -name daily_backup* -mtime +21 -exec rm -f {} ;

This command has two problems:

1.  The syntax is incorrect as the trailing ; needs to be \;

2.  More importantly, it can cause an error if you invoke it in a directory that has files that start with "daily_backup" because the * is not quoted, shell globbing will be active.

For example, if you invoke the find command and you have the files

daily_backup1
daily_backup2

then the shell effectively changes that to

find /backup/logs/ -name daily_backup1 daily_backup2 ....

which is a syntax error.

The correct way is to do

find /backup/logs/ -name "daily_backup*" -exec rm -f {} \;

or to be extra safe, add -type f to only match files, i.e.:

find /backup/logs/ -type f -name "daily_backup*" -exec rm -f {} \;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jcob_lAuthor Commented:
yes
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.