LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-13-2011, 12:46 AM   #1
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Rep: Reputation: 1
Question 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?
 
Old 04-13-2011, 12:57 AM   #2
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 148Reputation: 148
Code:
find -mmin '-5'
Finds files modified in the last five minutes.

Last edited by Telengard; 04-13-2011 at 02:55 PM. Reason: Forgot the -
 
Old 04-13-2011, 01:00 AM   #3
NM04
Member
 
Registered: Jan 2011
Distribution: Back Track,Fedora,centos
Posts: 240

Rep: Reputation: 14
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.
 
1 members found this post helpful.
Old 04-13-2011, 01:02 AM   #4
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
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

Last edited by brownie_cookie; 04-13-2011 at 01:03 AM.
 
Old 04-13-2011, 01:23 AM   #5
GVrooman
Member
 
Registered: May 2008
Distribution: Slackware
Posts: 45

Rep: Reputation: 11
You can also cd to the directory and type:

ls -lt | more
 
1 members found this post helpful.
Old 04-13-2011, 03:03 PM   #6
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by GVrooman View Post
ls -lt | more
Other useful variants:

Code:
ls -lt | less
ls -lt | head
 
Old 04-15-2011, 12:33 PM   #7
Bodi
LQ Newbie
 
Registered: Jul 2009
Posts: 25

Rep: Reputation: 2
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 ./

Last edited by Bodi; 04-15-2011 at 12:35 PM.
 
Old 04-15-2011, 01:07 PM   #8
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
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.
 
1 members found this post helpful.
Old 04-17-2011, 05:05 AM   #9
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Original Poster
Rep: Reputation: 1
Thanks arizonagroovejet!
 
Old 05-13-2012, 06:47 PM   #10
kosa777777
LQ Newbie
 
Registered: May 2012
Posts: 7

Rep: Reputation: Disabled
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:
 
  


Reply

Tags
file, find, modified


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
find files with pattern, then copy those files to another directory ncsuapex Programming 4 08-13-2010 03:38 PM
Is there a way to find out the history of a file written by users ZAMO Linux - Security 2 01-27-2009 01:39 PM
Is there a way to find recently created/edited files without using find? BrianK Linux - General 2 10-15-2007 09:41 PM
how to find out which files increase most recently? jimmyjiang Linux - Server 1 12-11-2006 10:57 AM
How to get last file written to directory kd5giv Linux - Networking 4 03-29-2004 02:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration