Results 1 to 3 of 3
I had a doubt with what the following kind of statement is going to accomplish. The statement is:-
--------------------------------------------------------------------------------------
find /backup/ -name '*.gz' -mtime +2 -print -exec rm {} \;
...
- 05-11-2009 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 33
Meaning of "find /backup/ -name '*.gz' -mtime +2 -print -exec rm {} \;"
I had a doubt with what the following kind of statement is going to accomplish. The statement is:-
--------------------------------------------------------------------------------------
find /backup/ -name '*.gz' -mtime +2 -print -exec rm {} \;
--------------------------------------------------------------------------------------
As per, my understanding, it is going to check in '/backup' path for all the files ending with 'gz' which were modified more than 48 hrs ago. Is, my understanding correct?
I hope, my question is clear.
Please, help in solving the doubt.
regards
- 05-11-2009 #2
yes,you are almost correct,
let's split this commandCode:find /backup/ -name '*.gz' -mtime +2 -print -exec rm {} \;
this will check for files under specified directory (which is backup)find /backup/
with find you can use plenty of options check "man find"
hereis used to retrieve all files which as .gz as extentsion.-name '*.gz'
tells to get files that are last modified 2 days ago.-mtime +2
-print option will display the file name
find is very powerful command especially when it's used along with
with -exec you can specify the action that needs to be taken on each retrieved fiiles-exec
here you using rm command , so it will delete files..
Above command will delete .gz files from /backup which are older than 2 days .- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 05-11-2009 #3Just Joined!
- Join Date
- Nov 2008
- Posts
- 33
thanks, a lot for your answer. You explained it very well.
regards


Reply With Quote