LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-13-2006, 01:16 AM   #1
madtinkerer
LQ Newbie
 
Registered: Sep 2006
Posts: 22

Rep: Reputation: 15
Bash: keeping track of newly added files


I know what I am about to propose could probably be taken care of by some subversion software, but I'd like to try it with a bash script and crontab.

I have a server setup which my co-workers use to share activities, lesson plans, etc for our classes. It works well but it is hard to keep track of newly added material. I've currently got it set up so that each coworker has their own /home/user directory, each with 3 directories - activities, assessments, outlines. I'd like to create a 4th directory called something like /home/user/new additions. I'd then like to make a bash script that would check the other directories daily for newly added material and create a link from that material in the new additions folder and then delete those links after a week or so. I've only got a little bash scripting experience and I idea how to do this. Can anyone make some suggestions?

Thanks a lot.
 
Old 09-13-2006, 01:22 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
by the way, do you have anything started yet?
 
Old 09-13-2006, 03:27 AM   #3
madtinkerer
LQ Newbie
 
Registered: Sep 2006
Posts: 22

Original Poster
Rep: Reputation: 15
Ah, no. I really have no idea how to do this. I was thinking of something along the lines of using the output from ls to get a creation date for the file and then comparing that to the current system time. If thats is less than 7 days, a link will be created in the directory I talked about. Now, exactly how to do that....
 
Old 09-13-2006, 03:48 AM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
...
I'd then like to make a bash script that would check the other directories daily for newly added material ...
last time i used to do this:

create a hidden file (or any regular file) by touching it in the directory you want to check for new files.

eg touch .dummy

This will create a dummy file with a timestamp
Then i will use the find command with the -newer switch to check for new files created after .dummy.

you can give this a try.

Quote:
...
create a link from that material in the new additions folder and then delete those links after a week or so...
...
you could use -exec of the find command (or xargs) to create links after finding newer files..

Then to delete those links after a week, you can use -mtime of the find command.

just some suggestions.
 
Old 09-13-2006, 08:52 AM   #5
madtinkerer
LQ Newbie
 
Registered: Sep 2006
Posts: 22

Original Poster
Rep: Reputation: 15
I think I followed that. Thanks for the help. I'll try out those suggestions and get back to you if I have any problems. Thanks
 
Old 09-13-2006, 09:30 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
With a little bit of tweaking you could even recycle say http://www.linuxquestions.org/questi...80#post2420380
 
  


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
Keeping track of my threads? une LQ Suggestions & Feedback 4 04-10-2005 10:35 PM
logrotate log files - keeping in order when using grep or cat and bash dmellem Linux - Software 6 02-11-2005 01:05 PM
Keeping track of packages NSKL Slackware 2 06-28-2002 10:23 PM
Deleting the newly created files keeping the existing icorsi Linux - Newbie 2 10-07-2001 11:16 AM
Deleting newly created files keeping the existing ones icorsi Linux - General 0 10-07-2001 12:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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