LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   finding new files (https://www.linuxquestions.org/questions/linux-newbie-8/finding-new-files-895711/)

niharikaananth 08-05-2011 05:31 AM

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

kirukan 08-05-2011 05:48 AM

Quote:

find /path -mtime +1 -print
find will help you to search files

niharikaananth 08-08-2011 02:11 AM

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 (Post 4434423)
find will help you to search files


Mr. Alex 08-08-2011 03:43 AM

kirukan, "-print" is not necessary.

paulmarc 08-08-2011 04:11 AM

How to exclude hidden entries and +1 meaning
 
Quote:

Originally Posted by niharikaananth (Post 4436517)
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?

kirukan 08-08-2011 04:27 AM

Yes Mr. Alex,
Please refer the following thread
http://www.linuxquestions.org/questi...olders-208169/

paulmarc 08-08-2011 05:19 AM

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

niharikaananth 08-08-2011 05:55 AM

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 (Post 4436598)
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?


niharikaananth 08-08-2011 06:05 AM

finding new files
 
Hey..Thank you very much for giving this useful link.

Quote:

Originally Posted by kirukan (Post 4436610)
Yes Mr. Alex,
Please refer the following thread
http://www.linuxquestions.org/questi...olders-208169/


paulmarc 08-08-2011 06:13 AM

Can use -2 for at most 2 days
 
Quote:

Originally Posted by niharikaananth (Post 4436675)
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"...


All times are GMT -5. The time now is 12:04 AM.