How to delete older files in a folder in unix?
up vote
1
down vote
favorite
I need to find the meaning of the below statement:
find /sourcedirectory -mtime +2 -exec mv "{}" /destination/directory/ ;
shell find
migrated from serverfault.com Aug 14 '14 at 11:14
This question came from our site for system and network administrators.
add a comment |
up vote
1
down vote
favorite
I need to find the meaning of the below statement:
find /sourcedirectory -mtime +2 -exec mv "{}" /destination/directory/ ;
shell find
migrated from serverfault.com Aug 14 '14 at 11:14
This question came from our site for system and network administrators.
1
Next time, please specify which Unix you're talking about. (Or as in this case, which find.) AIX is not FreeBSD is not OS X, for example.
– a CVn
Aug 12 '14 at 13:09
1
Also, the title and the question do not match.
– a CVn
Aug 12 '14 at 13:10
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I need to find the meaning of the below statement:
find /sourcedirectory -mtime +2 -exec mv "{}" /destination/directory/ ;
shell find
I need to find the meaning of the below statement:
find /sourcedirectory -mtime +2 -exec mv "{}" /destination/directory/ ;
shell find
shell find
edited Nov 25 at 14:29
Rui F Ribeiro
38.3k1475126
38.3k1475126
asked Aug 12 '14 at 9:16
Anna Vincent
migrated from serverfault.com Aug 14 '14 at 11:14
This question came from our site for system and network administrators.
migrated from serverfault.com Aug 14 '14 at 11:14
This question came from our site for system and network administrators.
1
Next time, please specify which Unix you're talking about. (Or as in this case, which find.) AIX is not FreeBSD is not OS X, for example.
– a CVn
Aug 12 '14 at 13:09
1
Also, the title and the question do not match.
– a CVn
Aug 12 '14 at 13:10
add a comment |
1
Next time, please specify which Unix you're talking about. (Or as in this case, which find.) AIX is not FreeBSD is not OS X, for example.
– a CVn
Aug 12 '14 at 13:09
1
Also, the title and the question do not match.
– a CVn
Aug 12 '14 at 13:10
1
1
Next time, please specify which Unix you're talking about. (Or as in this case, which find.) AIX is not FreeBSD is not OS X, for example.
– a CVn
Aug 12 '14 at 13:09
Next time, please specify which Unix you're talking about. (Or as in this case, which find.) AIX is not FreeBSD is not OS X, for example.
– a CVn
Aug 12 '14 at 13:09
1
1
Also, the title and the question do not match.
– a CVn
Aug 12 '14 at 13:10
Also, the title and the question do not match.
– a CVn
Aug 12 '14 at 13:10
add a comment |
1 Answer
1
active
oldest
votes
up vote
7
down vote
It means that every file or folder under /sourcedirectory older than two days should be moved to /destination/directory/.
find /sourcedirectory # finds every file/folder
-mtime +2 # sort out files/folders older than 2 days
mv "{}" /destination/directory/ # move each result to destination folder
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
7
down vote
It means that every file or folder under /sourcedirectory older than two days should be moved to /destination/directory/.
find /sourcedirectory # finds every file/folder
-mtime +2 # sort out files/folders older than 2 days
mv "{}" /destination/directory/ # move each result to destination folder
add a comment |
up vote
7
down vote
It means that every file or folder under /sourcedirectory older than two days should be moved to /destination/directory/.
find /sourcedirectory # finds every file/folder
-mtime +2 # sort out files/folders older than 2 days
mv "{}" /destination/directory/ # move each result to destination folder
add a comment |
up vote
7
down vote
up vote
7
down vote
It means that every file or folder under /sourcedirectory older than two days should be moved to /destination/directory/.
find /sourcedirectory # finds every file/folder
-mtime +2 # sort out files/folders older than 2 days
mv "{}" /destination/directory/ # move each result to destination folder
It means that every file or folder under /sourcedirectory older than two days should be moved to /destination/directory/.
find /sourcedirectory # finds every file/folder
-mtime +2 # sort out files/folders older than 2 days
mv "{}" /destination/directory/ # move each result to destination folder
answered Aug 12 '14 at 9:20
SteffenNielsen
1713
1713
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f150225%2fhow-to-delete-older-files-in-a-folder-in-unix%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Next time, please specify which Unix you're talking about. (Or as in this case, which find.) AIX is not FreeBSD is not OS X, for example.
– a CVn
Aug 12 '14 at 13:09
1
Also, the title and the question do not match.
– a CVn
Aug 12 '14 at 13:10