Find files older than a given file - a few hoursFind files which are created a certain time after or before a...
About opening an LLC with little to report in the beginning
Is it possible to spoof an IP address to an exact number?
How can solar sailed ships be protected from space debris?
Does Evolution Sage proliferate Blast Zone when played?
Should you add specific garden-fresh herbs to a stew at the beginning or the end?
How should I present a resort brochure in my general fiction?
How to deal with administrative duties killing the research spirit?
Data normalization before or after train-test split?
Does a multiclassed wizard start with a spellbook?
Bypass with wrong cvv of debit card and getting OTP
What is the maximum amount of diamond in one Minecraft game?
Could you sell yourself into slavery in the USA?
Is it bad to suddenly introduce another element to your fantasy world a good ways into the story?
Two queries on triangles, the sides of which have rational lengths
Has chattel slavery ever been used as a criminal punishment in the USA since the passage of the Thirteenth Amendment?
Taking advantage when the HR forgets to communicate the rules
Isn't "Dave's protocol" good if only the database, and not the code, is leaked?
Why does the Batman "crack his knuckles" in "Batman: Arkham Origins"?
How to travel between two stationary worlds in the least amount of time? (time dilation)
Has there ever been a cold war other than between the U.S. and the U.S.S.R.?
What/Where usage English vs Japanese
Machine Learning Golf: Multiplication
What does this value mean in a BJT datasheet?
List of Implementations for common OR problems
Find files older than a given file - a few hours
Find files which are created a certain time after or before a particular file was createdWhy does find -mtime +1 only return files older than 2 days?Find files older than x amount of time in specific directory with ignoring subdirectoriesdelete folders older than 1 dayRemove old files in a directory except files present in an exception fileDelete files older than 500 daysfind log files older than 30 days periodfind and delete files older than specific days and have specific string in filenamesSearch for newest file and see if file is older than 'X' dateRemoving files under particular conditions (number of files, file age)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'm using the following to find all files that are older than a reference file...
find /home/testuser -name "dummyfiles*" ! -newer referencefile.txt
... which works as expected.
However, I want to add a bit of leniency to the time, so that it only finds files that are older than the reference file - a few hours.
For example, if I have a reference file with modification date May 26 11:26, I want to find files that are older than May 26 9:26 (ie, with a 2-hour leniency on the reference file).
In this example, the following would be correct matches...
May 26 7:00
Apr 15 14:00
... and the following should not match...
Jun 13 9:00
May 26 10:00
Ultimately I want to delete all the files that I find, so would love it if find was able to handle this requirement? Otherwise, are there any other alternatives that will allow me to delete these files without being too convoluted?
find ksh
bumped to the homepage by Community♦ 18 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I'm using the following to find all files that are older than a reference file...
find /home/testuser -name "dummyfiles*" ! -newer referencefile.txt
... which works as expected.
However, I want to add a bit of leniency to the time, so that it only finds files that are older than the reference file - a few hours.
For example, if I have a reference file with modification date May 26 11:26, I want to find files that are older than May 26 9:26 (ie, with a 2-hour leniency on the reference file).
In this example, the following would be correct matches...
May 26 7:00
Apr 15 14:00
... and the following should not match...
Jun 13 9:00
May 26 10:00
Ultimately I want to delete all the files that I find, so would love it if find was able to handle this requirement? Otherwise, are there any other alternatives that will allow me to delete these files without being too convoluted?
find ksh
bumped to the homepage by Community♦ 18 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Please, can you clarify if you are looking for 1) files older than the reference file 2hour OR more than 2hour (>=) 2) files that are older that the reference file exactly 2 hour. (=)
– lese
Nov 6 '15 at 8:52
I'm looking for files that are older that the reference file less 2 hours. See the example in my question - in the example, I would want all files that are older thanMay 26 9:26, so it should also match files with datesMay 26 7:00,Apr 15 14:50, ... but not match datesJun 13 9:00orMay 26 10:00.
– wattostudios
Nov 9 '15 at 2:30
add a comment |
I'm using the following to find all files that are older than a reference file...
find /home/testuser -name "dummyfiles*" ! -newer referencefile.txt
... which works as expected.
However, I want to add a bit of leniency to the time, so that it only finds files that are older than the reference file - a few hours.
For example, if I have a reference file with modification date May 26 11:26, I want to find files that are older than May 26 9:26 (ie, with a 2-hour leniency on the reference file).
In this example, the following would be correct matches...
May 26 7:00
Apr 15 14:00
... and the following should not match...
Jun 13 9:00
May 26 10:00
Ultimately I want to delete all the files that I find, so would love it if find was able to handle this requirement? Otherwise, are there any other alternatives that will allow me to delete these files without being too convoluted?
find ksh
I'm using the following to find all files that are older than a reference file...
find /home/testuser -name "dummyfiles*" ! -newer referencefile.txt
... which works as expected.
However, I want to add a bit of leniency to the time, so that it only finds files that are older than the reference file - a few hours.
For example, if I have a reference file with modification date May 26 11:26, I want to find files that are older than May 26 9:26 (ie, with a 2-hour leniency on the reference file).
In this example, the following would be correct matches...
May 26 7:00
Apr 15 14:00
... and the following should not match...
Jun 13 9:00
May 26 10:00
Ultimately I want to delete all the files that I find, so would love it if find was able to handle this requirement? Otherwise, are there any other alternatives that will allow me to delete these files without being too convoluted?
find ksh
find ksh
edited Nov 9 '15 at 2:33
wattostudios
asked Oct 29 '15 at 0:19
wattostudioswattostudios
1066 bronze badges
1066 bronze badges
bumped to the homepage by Community♦ 18 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 18 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Please, can you clarify if you are looking for 1) files older than the reference file 2hour OR more than 2hour (>=) 2) files that are older that the reference file exactly 2 hour. (=)
– lese
Nov 6 '15 at 8:52
I'm looking for files that are older that the reference file less 2 hours. See the example in my question - in the example, I would want all files that are older thanMay 26 9:26, so it should also match files with datesMay 26 7:00,Apr 15 14:50, ... but not match datesJun 13 9:00orMay 26 10:00.
– wattostudios
Nov 9 '15 at 2:30
add a comment |
Please, can you clarify if you are looking for 1) files older than the reference file 2hour OR more than 2hour (>=) 2) files that are older that the reference file exactly 2 hour. (=)
– lese
Nov 6 '15 at 8:52
I'm looking for files that are older that the reference file less 2 hours. See the example in my question - in the example, I would want all files that are older thanMay 26 9:26, so it should also match files with datesMay 26 7:00,Apr 15 14:50, ... but not match datesJun 13 9:00orMay 26 10:00.
– wattostudios
Nov 9 '15 at 2:30
Please, can you clarify if you are looking for 1) files older than the reference file 2hour OR more than 2hour (>=) 2) files that are older that the reference file exactly 2 hour. (=)
– lese
Nov 6 '15 at 8:52
Please, can you clarify if you are looking for 1) files older than the reference file 2hour OR more than 2hour (>=) 2) files that are older that the reference file exactly 2 hour. (=)
– lese
Nov 6 '15 at 8:52
I'm looking for files that are older that the reference file less 2 hours. See the example in my question - in the example, I would want all files that are older than
May 26 9:26, so it should also match files with dates May 26 7:00, Apr 15 14:50, ... but not match dates Jun 13 9:00 or May 26 10:00.– wattostudios
Nov 9 '15 at 2:30
I'm looking for files that are older that the reference file less 2 hours. See the example in my question - in the example, I would want all files that are older than
May 26 9:26, so it should also match files with dates May 26 7:00, Apr 15 14:50, ... but not match dates Jun 13 9:00 or May 26 10:00.– wattostudios
Nov 9 '15 at 2:30
add a comment |
1 Answer
1
active
oldest
votes
Try out with this :
find /home/testuser -name "dummyfiles*" ! -newer referencefile.txt -mmin +120 -print
adding the parameter -mmin +120 find command will return only the files older than 2-hour in comparison to referencefile.txt modification date.
test:
mkdir find
touch find/dummyfiles1 find/dummyfiles2 find/dummyfiles3 find/dummyfiles4 find/referencefile.txt
touch -t 8001031305 dummyfiles1 dummyfiles2
find find/ -name "dummyfiles*" ! -newer find/referencefile.txt -mmin +120
output:
find/dummyfiles1
find/dummyfiles2
1
You should explain why your solution is different to what the OP is already doing, and how it solves their problem.
– cas
Oct 29 '15 at 6:33
Improved the answer, It was so late in my country : )
– lese
Oct 29 '15 at 8:53
No, this doesn't do what you claim. This command matches files that are older thanreferencefile.txtand at least two hours old. Nothing here says “two hours older than the reference file”.
– Gilles
Oct 31 '15 at 23:00
This answer do exaclty what I claim (don't call me storyteller) : "return only the files older than 2-hour"(it's what I'm claiming). Anyway, maybe I missed understood the question. Waiting for a clarification from the OP
– lese
Nov 6 '15 at 8:54
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f239374%2ffind-files-older-than-a-given-file-a-few-hours%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try out with this :
find /home/testuser -name "dummyfiles*" ! -newer referencefile.txt -mmin +120 -print
adding the parameter -mmin +120 find command will return only the files older than 2-hour in comparison to referencefile.txt modification date.
test:
mkdir find
touch find/dummyfiles1 find/dummyfiles2 find/dummyfiles3 find/dummyfiles4 find/referencefile.txt
touch -t 8001031305 dummyfiles1 dummyfiles2
find find/ -name "dummyfiles*" ! -newer find/referencefile.txt -mmin +120
output:
find/dummyfiles1
find/dummyfiles2
1
You should explain why your solution is different to what the OP is already doing, and how it solves their problem.
– cas
Oct 29 '15 at 6:33
Improved the answer, It was so late in my country : )
– lese
Oct 29 '15 at 8:53
No, this doesn't do what you claim. This command matches files that are older thanreferencefile.txtand at least two hours old. Nothing here says “two hours older than the reference file”.
– Gilles
Oct 31 '15 at 23:00
This answer do exaclty what I claim (don't call me storyteller) : "return only the files older than 2-hour"(it's what I'm claiming). Anyway, maybe I missed understood the question. Waiting for a clarification from the OP
– lese
Nov 6 '15 at 8:54
add a comment |
Try out with this :
find /home/testuser -name "dummyfiles*" ! -newer referencefile.txt -mmin +120 -print
adding the parameter -mmin +120 find command will return only the files older than 2-hour in comparison to referencefile.txt modification date.
test:
mkdir find
touch find/dummyfiles1 find/dummyfiles2 find/dummyfiles3 find/dummyfiles4 find/referencefile.txt
touch -t 8001031305 dummyfiles1 dummyfiles2
find find/ -name "dummyfiles*" ! -newer find/referencefile.txt -mmin +120
output:
find/dummyfiles1
find/dummyfiles2
1
You should explain why your solution is different to what the OP is already doing, and how it solves their problem.
– cas
Oct 29 '15 at 6:33
Improved the answer, It was so late in my country : )
– lese
Oct 29 '15 at 8:53
No, this doesn't do what you claim. This command matches files that are older thanreferencefile.txtand at least two hours old. Nothing here says “two hours older than the reference file”.
– Gilles
Oct 31 '15 at 23:00
This answer do exaclty what I claim (don't call me storyteller) : "return only the files older than 2-hour"(it's what I'm claiming). Anyway, maybe I missed understood the question. Waiting for a clarification from the OP
– lese
Nov 6 '15 at 8:54
add a comment |
Try out with this :
find /home/testuser -name "dummyfiles*" ! -newer referencefile.txt -mmin +120 -print
adding the parameter -mmin +120 find command will return only the files older than 2-hour in comparison to referencefile.txt modification date.
test:
mkdir find
touch find/dummyfiles1 find/dummyfiles2 find/dummyfiles3 find/dummyfiles4 find/referencefile.txt
touch -t 8001031305 dummyfiles1 dummyfiles2
find find/ -name "dummyfiles*" ! -newer find/referencefile.txt -mmin +120
output:
find/dummyfiles1
find/dummyfiles2
Try out with this :
find /home/testuser -name "dummyfiles*" ! -newer referencefile.txt -mmin +120 -print
adding the parameter -mmin +120 find command will return only the files older than 2-hour in comparison to referencefile.txt modification date.
test:
mkdir find
touch find/dummyfiles1 find/dummyfiles2 find/dummyfiles3 find/dummyfiles4 find/referencefile.txt
touch -t 8001031305 dummyfiles1 dummyfiles2
find find/ -name "dummyfiles*" ! -newer find/referencefile.txt -mmin +120
output:
find/dummyfiles1
find/dummyfiles2
edited Oct 29 '15 at 9:04
answered Oct 29 '15 at 2:07
leselese
2,1153 gold badges13 silver badges27 bronze badges
2,1153 gold badges13 silver badges27 bronze badges
1
You should explain why your solution is different to what the OP is already doing, and how it solves their problem.
– cas
Oct 29 '15 at 6:33
Improved the answer, It was so late in my country : )
– lese
Oct 29 '15 at 8:53
No, this doesn't do what you claim. This command matches files that are older thanreferencefile.txtand at least two hours old. Nothing here says “two hours older than the reference file”.
– Gilles
Oct 31 '15 at 23:00
This answer do exaclty what I claim (don't call me storyteller) : "return only the files older than 2-hour"(it's what I'm claiming). Anyway, maybe I missed understood the question. Waiting for a clarification from the OP
– lese
Nov 6 '15 at 8:54
add a comment |
1
You should explain why your solution is different to what the OP is already doing, and how it solves their problem.
– cas
Oct 29 '15 at 6:33
Improved the answer, It was so late in my country : )
– lese
Oct 29 '15 at 8:53
No, this doesn't do what you claim. This command matches files that are older thanreferencefile.txtand at least two hours old. Nothing here says “two hours older than the reference file”.
– Gilles
Oct 31 '15 at 23:00
This answer do exaclty what I claim (don't call me storyteller) : "return only the files older than 2-hour"(it's what I'm claiming). Anyway, maybe I missed understood the question. Waiting for a clarification from the OP
– lese
Nov 6 '15 at 8:54
1
1
You should explain why your solution is different to what the OP is already doing, and how it solves their problem.
– cas
Oct 29 '15 at 6:33
You should explain why your solution is different to what the OP is already doing, and how it solves their problem.
– cas
Oct 29 '15 at 6:33
Improved the answer, It was so late in my country : )
– lese
Oct 29 '15 at 8:53
Improved the answer, It was so late in my country : )
– lese
Oct 29 '15 at 8:53
No, this doesn't do what you claim. This command matches files that are older than
referencefile.txt and at least two hours old. Nothing here says “two hours older than the reference file”.– Gilles
Oct 31 '15 at 23:00
No, this doesn't do what you claim. This command matches files that are older than
referencefile.txt and at least two hours old. Nothing here says “two hours older than the reference file”.– Gilles
Oct 31 '15 at 23:00
This answer do exaclty what I claim (don't call me storyteller) : "return only the files older than 2-hour"(it's what I'm claiming). Anyway, maybe I missed understood the question. Waiting for a clarification from the OP
– lese
Nov 6 '15 at 8:54
This answer do exaclty what I claim (don't call me storyteller) : "return only the files older than 2-hour"(it's what I'm claiming). Anyway, maybe I missed understood the question. Waiting for a clarification from the OP
– lese
Nov 6 '15 at 8:54
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f239374%2ffind-files-older-than-a-given-file-a-few-hours%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
Please, can you clarify if you are looking for 1) files older than the reference file 2hour OR more than 2hour (>=) 2) files that are older that the reference file exactly 2 hour. (=)
– lese
Nov 6 '15 at 8:52
I'm looking for files that are older that the reference file less 2 hours. See the example in my question - in the example, I would want all files that are older than
May 26 9:26, so it should also match files with datesMay 26 7:00,Apr 15 14:50, ... but not match datesJun 13 9:00orMay 26 10:00.– wattostudios
Nov 9 '15 at 2:30