LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 08-05-2011, 06:31 AM   #1
niharikaananth
Member
 
Registered: Aug 2011
Posts: 58

Rep: Reputation: Disabled
finding new files


Hi...when multiple subdirectories are under a main directory, how can I find only new files i.e from last 1 are two days modified or new files . Hope someone will definetely help this.

Regards
Niharika
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 08-05-2011, 06:48 AM   #2
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,274

Rep: Reputation: 148Reputation: 148
Quote:
find /path -mtime +1 -print
find will help you to search files
 
2 members found this post helpful.
Old 08-08-2011, 03:11 AM   #3
niharikaananth
Member
 
Registered: Aug 2011
Posts: 58

Original Poster
Rep: Reputation: Disabled
finding new files

As you said I did as "find /home/my_home_dir -mtime +1 -print", But it is giving around 1442 files information which is also included .Mozilla, .thunderbird, .thumbnail, .metacity files, I don't want these files info. So how can I exculde these hidden directories info, And what does +1 means in this command? Is it since last one day?


Quote:
Originally Posted by kirukan View Post
find will help you to search files
 
Old 08-08-2011, 04:43 AM   #4
Mr. Alex
Senior Member
 
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238

Rep: Reputation: Disabled
kirukan, "-print" is not necessary.
 
Old 08-08-2011, 05:11 AM   #5
paulmarc
LQ Newbie
 
Registered: Jul 2011
Distribution: Fedora
Posts: 11

Rep: Reputation: 4
Post How to exclude hidden entries and +1 meaning

Quote:
Originally Posted by niharikaananth View Post
it [...] included .Mozilla, .thunderbird, .thumbnail, .metacity files, I don't want these files...
You can exclude these files by having ./* as your search path:
Code:
find ./* -mtime +1
You can omit -print as it's used by default.
The +n means the files are at least n*24 hours old: with n=1, it's at least (more than) 24 hours old, or at least 2 days old.

Is that what you want?
 
1 members found this post helpful.
Old 08-08-2011, 05:27 AM   #6
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,274

Rep: Reputation: 148Reputation: 148
Yes Mr. Alex,
Please refer the following thread
http://www.linuxquestions.org/questi...olders-208169/
 
1 members found this post helpful.
Old 08-08-2011, 06:19 AM   #7
paulmarc
LQ Newbie
 
Registered: Jul 2011
Distribution: Fedora
Posts: 11

Rep: Reputation: 4
Post Only excluding 1st-level hidden entries

Note that the solution I mentioned only excludes the 1st-level entries, meaning the hidden directories and files in the main search directory won't be included.
So to exclude ".mozilla", ".metacity" and so forth, you use what I wrote before:
Code:
find ./* -mtime +1
This is effectively searching everything non-hidden in the main directory.

However, if you have hidden entries INSIDE the non-hidden, 1st-level entries, they will still be listed.
To exclude hidden matches (if you don't want hidden files to be shown in your search query), you can additionally use the -not -name modifier:
Code:
find ./* -not -name ".*" -mtime +1
 
Old 08-08-2011, 06:55 AM   #8
niharikaananth
Member
 
Registered: Aug 2011
Posts: 58

Original Poster
Rep: Reputation: Disabled
finding new files

Yes you are correct, But now if I used "find ./* -mtime +1", But it is showing all old files older than a day, but excuding hidden directories.
But I need new files of last one or two days. So I ran "-1" instead of "+1" & found only new files which are belongs to since last 24 hours.
Anyway Thank you very much for your kind help.

Quote:
Originally Posted by paulmarc View Post
You can exclude these files by having ./* as your search path:
Code:
find ./* -mtime +1
You can omit -print as it's used by default.
The +n means the files are at least n*24 hours old: with n=1, it's at least (more than) 24 hours old, or at least 2 days old.

Is that what you want?
 
Old 08-08-2011, 07:05 AM   #9
niharikaananth
Member
 
Registered: Aug 2011
Posts: 58

Original Poster
Rep: Reputation: Disabled
finding new files

Hey..Thank you very much for giving this useful link.

Quote:
Originally Posted by kirukan View Post
Yes Mr. Alex,
Please refer the following thread
http://www.linuxquestions.org/questi...olders-208169/
 
Old 08-08-2011, 07:13 AM   #10
paulmarc
LQ Newbie
 
Registered: Jul 2011
Distribution: Fedora
Posts: 11

Rep: Reputation: 4
Post Can use -2 for at most 2 days

Quote:
Originally Posted by niharikaananth View Post
But I need new files of last one or two days.
You can always specify -2 to have at most 2 days, if you want:
Code:
find ./* -mtime -2
When you use minus/dash '-', the logic is "at most", and when you use plus '+', it's "at least"...

Last edited by paulmarc; 08-08-2011 at 07:14 AM.
 
  


Reply


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
Finding multiple files with ascending numerical files extensions unim21 Linux - Newbie 3 04-23-2009 08:50 PM
when finding files in Konqueror, why use the files index? newbiesforever Linux - General 4 03-20-2009 10:06 AM
Finding files and then finding content within those files... Maeltor Linux - Software 5 03-13-2007 01:06 PM
finding files in C++ poeta_boy Programming 2 07-11-2004 02:25 AM
Finding files Nicksan Linux - Software 3 06-30-2003 08:16 PM


All times are GMT -5. The time now is 03: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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration