[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] bash native way to support test file is older than a cer
Andreas Kusalananda Kähäri
Re: [Help-bash] bash native way to support test file is older than a certain period of time
Sun, 9 Jun 2019 22:51:51 +0200
On Sun, Jun 09, 2019 at 03:32:07PM -0500, Peng Yu wrote:
> I don't find a bash native way to test if a file is older than a
> certain period of time. Is there not a native way to do so? Thanks.
There is the -nt ("newer than") test, but that needs a reference file to
test against. You could create such a file with the touch utility.
The other alternative is to use find:
if [ -n "$( find "$myfile" -mmin +60 -print)" ]; then
echo file was modified more than 60 minutes ago
(where "$myfile" is some path to a file)
There's nothing "bash native" about that though, but it would be