Find a file by date (or time) [Solved]

Post here if you are a new Porteus member and you're looking for some help.
Post Reply
User avatar
Ed_P
Contributor
Contributor
Posts: 3314
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Find a file by date (or time) [Solved]

Post#1 by Ed_P » 22 Aug 2014, 19:57

How do I find a file in my /mnt/live/memory/changes/ directory that got changed by a specific date? I don't remember the file's name so Find isn't helping but I know it got changed Wednesday. ls /mnt/live/memory/changes/ doesn't do it.

BTW

Code: Select all

root@porteus:/home/guest# ls -help
/bin/ls: invalid option -- 'e'-/code]
Isn't the invalid option 'help'?
Last edited by Ed_P on 08 Oct 2014, 05:22, edited 1 time in total.
Ed

User avatar
Slaxmax
Contributor
Contributor
Posts: 403
Joined: 03 Jan 2013, 09:51
Distribution: KDE4
Location: Campinas Brazil https://goo.gl/yrxwKi

Re: Find a file by date

Post#2 by Slaxmax » 22 Aug 2014, 20:47

http://www.cyberciti.biz/faq/linux-unix ... s-by-date/
for me

Code: Select all

guest@porteus:~$ ls -l  | grep "6 Ago 22"
-rw-r--r-- 1 guest guest 6 Ago 22 17:50 testfile.txt

Code: Select all

guest@porteus:~$ ls --help
Uso: /bin/ls [OPÇÃO]... [ARQUIVO]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

pay attention correct is --help
“DNA is like a computer program but far, far more advanced than any software ever created.”
― Bill Gates, The Road Ahead

User avatar
Ed_P
Contributor
Contributor
Posts: 3314
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: Find a file by date

Post#3 by Ed_P » 22 Aug 2014, 21:24

Slaxmax wrote:http://www.cyberciti.biz/faq/linux-unix ... s-by-date/
for me

Code: Select all

guest@porteus:~$ ls -l  | grep "6 Ago 22"
-rw-r--r-- 1 guest guest 6 Ago 22 17:50 testfile.txt

Code: Select all

guest@porteus:~$ ls --help
Uso: /bin/ls [OPÇÃO]... [ARQUIVO]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

Thank you.
pay attention correct is --help
Yup.
Ed

cttan
Shogun
Shogun
Posts: 332
Joined: 26 Jan 2011, 16:15
Distribution: Porteus 3.2 64bit KDE
Location: Malaysia

Re: Find a file by date

Post#4 by cttan » 23 Aug 2014, 07:18

Hi Ed_P,

# find / -iname "*" -mtime +60 -print
# find / -iname "*" -mtime -60 -print
# find / -iname "*" -mtime 60 -print

You can use -mtime option. It returns list of file if the file was last accessed N*24 hours ago. For example to find file in last 2 months (60 days) you need to use -mtime +60 option.
-mtime +60 means you are looking for a file modified 60 days ago.
-mtime -60 means less than 60 days.
-mtime 60 If you skip + or - it means exactly 60 days.

User avatar
Ed_P
Contributor
Contributor
Posts: 3314
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: Find a file by date

Post#5 by Ed_P » 02 Sep 2014, 18:51

Thank you cttan.

Unfortunately for me the files in the /mnt/live/memory/changes/ directory all start with the time the system was booted. So if you booted today at 7:00am the oldest file date is today at 7:00am, even for files added or updated 3 days ago.
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 3314
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: Find a file by date

Post#6 by Ed_P » 08 Oct 2014, 05:21

Hi cttan

I revisited your # find command suggestions tonight and found this tweaked version to be very helpful identifying configuration changes I made. Rather than looking back days I looked back 5 minutes.

find /mnt/live/memory/changes -iname "*" -mmin -5

Thanks for your help. :beer:
Ed

Bogomips
Full of knowledge
Full of knowledge
Posts: 2563
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: Find a file by date

Post#7 by Bogomips » 08 Oct 2014, 11:45

cttan wrote:Hi Ed_P,

# find / -iname "*" -mtime +60 -print
# find / -iname "*" -mtime -60 -print
# find / -iname "*" -mtime 60 -print

You can use -mtime option. It returns list of file if the file was last accessed N*24 hours ago. For example to find file in last 2 months (60 days) you need to use -mtime +60 option.
-mtime +60 means you are looking for a file modified 60 days ago.
-mtime -60 means less than 60 days.
-mtime 60 If you skip + or - it means exactly 60 days.
Minor correction needed here. Also happen to have lost file downloaded two days ago. Tried suggested cli and got v. long list.

Code: Select all

 Numeric arguments can be specified as

       +n     for greater than n,

       -n     for less than n,

       n      for exactly n.
-mtime +60 means you are looking for a file modified more than 60 days ago.

Also useful could be

Code: Select all

find ~/path/to/dir/ -iname "*" -mtime -2 -maxdepth 1 -size +100M
if directory known. So less than 2 days ago greater than 100 MB.
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

Post Reply