Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 12-07-2004, 11:11 AM   #1
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?


Old 12-07-2004, 01:40 PM   #2
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
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

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

find / -cnewer ~/.stamp -type f 
touch ~/.stamp

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

Rep: Reputation: 61
Alternatively, you may compare to the script itself:
find / -newer "$0" -type f -print
touch "$0"
Old 12-08-2004, 04:43 AM   #5
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)


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

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


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 10:56 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration