LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to find a file which is being written recently in directory of 1000 files? (http://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-a-file-which-is-being-written-recently-in-directory-of-1000-files-874695/)

manalisharmabe 04-13-2011 01:46 AM

How to find a file which is being written recently in directory of 1000 files?
 
How to find a file which is being written recently in directory of 1000 files?

Telengard 04-13-2011 01:57 AM

Code:

find -mmin '-5'
Finds files modified in the last five minutes.

NM04 04-13-2011 02:00 AM

cd to the directory and execute this: find ./ -name "name of the file" -mtime -7.

1) better write the name of the file in the codes.
2) -mtime -7 will find files modified seven or fewer days ago. you can change the parameter.

cheers.

brownie_cookie 04-13-2011 02:02 AM

if you know a part of the name or the extension (.txt, .zip, ...)
try something like

Code:

find -mmin 5 | grep *.txt
because when you do only the find command, you get maybe more than 100 files , execute it with a pipeline and the grep command, you will be more specific , so you get a better view of your files
(because you said how to find A file, you can either try my suggestion or one of the above ;))

GL :hattip:

GVrooman 04-13-2011 02:23 AM

You can also cd to the directory and type:

ls -lt | more

Telengard 04-13-2011 04:03 PM

Quote:

Originally Posted by GVrooman (Post 4322958)
ls -lt | more

Other useful variants:

Code:

ls -lt | less
ls -lt | head


Bodi 04-15-2011 01:33 PM

Go inside the directory and try find ./ -name "filename", or find ./ -name "filename*"( if you do not the file extension ) . If you know how many days ago was the file was last edited, you can try find ./ -mtime 1 (or 2,3,4,5,etc the number represents how many days prior to the currect date). You can also try grep -r filename ./

arizonagroovejet 04-15-2011 02:07 PM

Another technique that might be useful

Code:

$ touch /tmp/now
Now do whatever it is that you think is writing to a file. Then run

Code:

$ find /path/to/directory -newer /tmp/now
That will list any files modified since /tmp/now was created.

manalisharmabe 04-17-2011 06:05 AM

Thanks arizonagroovejet!

kosa777777 05-13-2012 07:47 PM

Recently is a problem
 
I see you guys pretty much answered but let me add my 5 cents. You need to have idea how recently you want it to be. If you have an idea that it is 0-10 days ago you can generate a report like this:

Code:

# for i in {0..10};do echo "$i days ago:" ;find . -mtime $i ;done;
0 days ago:
.
./a
1 days ago:
2 days ago:
3 days ago:
4 days ago:
5 days ago:
6 days ago:
7 days ago:
8 days ago:
9 days ago:
10 days ago:



All times are GMT -5. The time now is 04:44 PM.