Page 1 of 1
Find a file by date (or time) [Solved]
Posted: 22 Aug 2014, 19:57
by Ed_P
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'?
Re: Find a file by date
Posted: 22 Aug 2014, 20:47
by Slaxmax
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
Re: Find a file by date
Posted: 22 Aug 2014, 21:24
by Ed_P
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.
Re: Find a file by date
Posted: 23 Aug 2014, 07:18
by cttan
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.
Re: Find a file by date
Posted: 02 Sep 2014, 18:51
by Ed_P
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.
Re: Find a file by date
Posted: 08 Oct 2014, 05:21
by Ed_P
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.
Re: Find a file by date
Posted: 08 Oct 2014, 11:45
by Bogomips
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.