LinuxQuestions.org
Visit Jeremy's Blog.
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 10-20-2012, 02:55 AM   #1
kumarjohn
LQ Newbie
 
Registered: Oct 2012
Posts: 22

Rep: Reputation: Disabled
script to search new files in subdirectories


Hi,

Greetings!!

I am newbie and started writing scripts few months back. I want to write a script to find the files and directories which were newly added to the existing directory structure.

My present directory structure is

dir1 has dir2,dir3,dir4 subdirectories and in ../dir1/dir2/ i have some more sub directories dir2.1 dir2.2

now I want the list files newly add anywhere in the directory structure.

Wishes,
KJ
 
Old 10-20-2012, 04:07 AM   #2
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,811
Blog Entries: 1

Rep: Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191
Hi and welcome to LQ.

What do you mean "new"? New relative to what? You can easily identify files created/modified in the last N minutes using the find command (see find manual page to see all its flags, eg: -mtime or -mmin). Alternatively google search will return a lot of results.

HTH
 
2 members found this post helpful.
Old 10-20-2012, 02:13 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
As above. In addition if you wanted to compare the current contents to some previous point in time, you'd probably have to store the names and date in a log file of some kind to compare against.
 
2 members found this post helpful.
Old 12-21-2012, 10:10 PM   #4
kumarjohn
LQ Newbie
 
Registered: Oct 2012
Posts: 22

Original Poster
Rep: Reputation: Disabled
Hi,

Greetings!!

Thanks sycamorex and David the H for the suggestion.

I have solved the issue using find command with -mtime option.

Best Regards,
KJ.
 
1 members found this post helpful.
  


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
[SOLVED] Search all tar.gz files in subdirectories for file scambro Linux - General 2 03-26-2012 05:28 PM
how to search a string in the files in the subdirectories wj123 Programming 4 03-10-2011 09:37 PM
Using Bash, Find script files in a directory or subdirectories within... ray5_83 Programming 4 10-10-2008 08:42 PM
script to search inside list of files adam_blackice Programming 5 03-25-2008 10:35 AM
Script For Moving Files In Subdirectories darkmage Linux - General 3 12-17-2002 07:34 PM


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