LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-20-2012, 01:55 AM   #1
kumarjohn
LQ Newbie
 
Registered: Oct 2012
Posts: 26

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, 03:07 AM   #2
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
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, 01:13 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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, 09:10 PM   #4
kumarjohn
LQ Newbie
 
Registered: Oct 2012
Posts: 26

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



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

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

All times are GMT -5. The time now is 02:31 AM.

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