LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 12-07-2004, 11:11 AM   #1
topcat
Member
 
Registered: Feb 2003
Distribution: ubuntu 6.06, ubuntu 7.04 AMD 64bit, 7.10 AMD 64bit
Posts: 62

Rep: Reputation: 15
shell scripting: checking for modified files


I was looking to write a shell script, that finds all of the files that have changed or been added new) since the last time the script was run.

the file and the entire path should be echoed.

can anyone jumpstart me?

thanks!

tc
 
Old 12-07-2004, 01:40 PM   #2
secesh
Senior Member
 
Registered: Sep 2004
Location: Savannah, GA
Distribution: Ubuntu, Gentoo, Mythbuntu, ClarkConnect
Posts: 1,154

Rep: Reputation: 47
i suppose the trick is knowing when the last run-time was... perhaps a file in /tmp?

then you could use something like find x -newer /tmp/myfile
 
Old 12-07-2004, 02:32 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,986
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
Yep, secesh's idea should work.
Before you first run it you touch ~/.stamp manually...

Code:
#!/bin/bash
find / -cnewer ~/.stamp -type f 
touch ~/.stamp


Cheers,
Tink
 
Old 12-08-2004, 03:06 AM   #4
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
Alternatively, you may compare to the script itself:
Code:
#!/bin/bash
find / -newer "$0" -type f -print
touch "$0"
Yves.
 
Old 12-08-2004, 04:43 AM   #5
topcat
Member
 
Registered: Feb 2003
Distribution: ubuntu 6.06, ubuntu 7.04 AMD 64bit, 7.10 AMD 64bit
Posts: 62

Original Poster
Rep: Reputation: 15
Thanks everyone. Got something working, though different from the above. Posting it here just in case someone needs it. let me know if there are any flaws in it?
It also copies the changed files to another server while retaining the permission.
The idea was to sync 2 servers. (Development and production)

#!/bin/bash

CP="/bin/cp -u -r -p -f -v"
DATE=`date -Iminutes`

$CP /root/copy/* /home/copy > newlist-$DATE
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Scripting and Files With Spaces Matir Programming 12 08-17-2005 01:43 AM
Shell scripting problem for importing Firefox files montylee Programming 6 06-03-2005 01:52 AM
Shell Scripting: How to pick lines out of files by line number. Louie55 Programming 3 03-22-2005 06:18 PM
Does anyone know how to move files to a particular directory using shell scripting RowanB Programming 3 11-11-2004 01:46 PM
Tar files in a dir modified before 7 days in a shell script jayachristina Linux - Newbie 4 05-14-2004 02:49 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration