LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 12-01-2008, 11:27 PM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 31
find the files in a directory


I would like to search the files in a directory which was created ( last modified date ) in pass two days ,

for example , today is 23-Dec , if I would like to search a files that was created in 21-Dec or 22-Dec , can advise what can i do ? thx
 
Old 12-01-2008, 11:34 PM   #2
RMLinux
Member
 
Registered: Jul 2006
Posts: 260

Rep: Reputation: 37
Quote:
Originally Posted by ust View Post
I would like to search the files in a directory which was created ( last modified date ) in pass two days ,

for example , today is 23-Dec , if I would like to search a files that was created in 21-Dec or 22-Dec , can advise what can i do ? thx
you type man find.

sample command# "find /var/* -name foo*.*"

search all files begin with foo. hope this will help you sorry my linux is down I cannot try the date :-)
 
Old 12-02-2008, 12:07 AM   #3
claudius753
Member
 
Registered: Jan 2004
Distribution: Mac OS X 10.6.4 "Snow Leopard", Win 7, Ubuntu 10.04
Posts: 322

Rep: Reputation: 31
I'm not sure for created date. For modified date, the flag is -mtime and for accessed date you would use -atime. So, files modified in the last 2 days
Code:
find /directory/path -mtime -2
The number is - for modified or accessed within that time, you can use + for files modified more than that number of days ago.
 
Old 12-02-2008, 12:36 AM   #4
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by claudius753 View Post
I'm not sure for created date. For modified date, the flag is -mtime and for accessed date you would use -atime. So, files modified in the last 2 days
Code:
find /directory/path -mtime -2
The number is - for modified or accessed within that time, you can use + for files modified more than that number of days ago.
thx reply ,

the -mtime -2 can check the file in 48 hours , if I want it check the file in whole day of 21th and 22th , can advise what can i do ?
 
Old 12-02-2008, 12:44 AM   #5
claudius753
Member
 
Registered: Jan 2004
Distribution: Mac OS X 10.6.4 "Snow Leopard", Win 7, Ubuntu 10.04
Posts: 322

Rep: Reputation: 31
Quote:
Originally Posted by ust View Post
thx reply ,

the -mtime -2 can check the file in 48 hours , if I want it check the file in whole day of 21th and 22th , can advise what can i do ?
I think if you added the flag -daystart it sets the beginning of the day as the start point? I'm not too sure.

Code:
find /path -daystart -mtime -2
 
Old 12-02-2008, 07:25 PM   #6
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 31
thx reply ,
I would like to have a more simple request , if I want to find all files BUT EXCEPT TODAY ( that means list all file except those created on today ) , what can i do ? thx
 
Old 12-02-2008, 07:58 PM   #7
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
-mtime +1
 
Old 12-02-2008, 10:05 PM   #8
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by billymayday View Post
-mtime +1
thx reply ,

-mtime +1 seems check the file that created within 24 hours , if I want to check the file not created on today , eg.today is 3-Dec , only find the file not in 3-Dec , it find the file in the whole day of 2-Dec , what can i do ? thx
 
Old 12-02-2008, 11:13 PM   #9
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
From man find
Code:
       +n     for greater than n,

       -n     for less than n,

       n      for exactly n.

       -mtime n
              File's data was last modified n*24 hours ago.  See the comments for -atime to understand how rounding affects  the  inter-
              pretation of file modification times.
 
Old 12-02-2008, 11:39 PM   #10
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by billymayday View Post
From man find
Code:
       +n     for greater than n,

       -n     for less than n,

       n      for exactly n.

       -mtime n
              File's data was last modified n*24 hours ago.  See the comments for -atime to understand how rounding affects  the  inter-
              pretation of file modification times.
thx reply ,

so it seems the -mtime n is not fit my requirement , i am not want to find n*24 hours ago , what I want is "not today" , can advise how to do it ? thx
 
Old 12-02-2008, 11:51 PM   #11
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Go back to the -daystart suggestion. Read "man find"

Try

Code:
find ./ -daystart -mtime +0
 
Old 12-03-2008, 12:24 AM   #12
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by billymayday View Post
Go back to the -daystart suggestion. Read "man find"

Try

Code:
find ./ -daystart -mtime +0
it works fine , thanks much.
 
  


Reply



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
Find files in current directory, not subdirectories SmurfGGM Linux - Newbie 1 10-09-2008 12:14 PM
find newest files in a directory macushk Linux - Newbie 3 05-05-2008 04:16 AM
Listing files in a directory without ls and find? szahri Linux - Newbie 11 03-23-2007 03:12 AM
How to find the date for all the files in a directory Uday123 AIX 6 02-23-2006 08:26 PM

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

All times are GMT -5. The time now is 10:05 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