The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to retrieve original contents of a modified file (modified using vi) novice100 UNIX for Dummies Questions & Answers 3 05-31-2007 05:50 PM
who modified my file!! mohanprabu UNIX for Dummies Questions & Answers 4 10-28-2005 07:18 PM
File last modified szzz High Level Programming 4 11-05-2003 08:44 AM
How do I get the last modified date of a file? akpopa UNIX for Dummies Questions & Answers 2 08-29-2001 12:08 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-26-2005
nimo
Guest
 

Posts: n/a
Check if file modified

Hi,
I have a monitoring script that I run, and I would like to automate checking if specific parameter file is modified during the last day or two. How do I do that?
Reply With Quote
Forum Sponsor
  #2  
Old 05-26-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Here is a very crude script(qualifies well for 'how not to write a script').

Learning phase for me

Hopefully a much better solution would come up.

Code:
#! /bin/sh

FILE=/file/to/check
DoC=echo `stat -c=%y $FILE | awk -F"-" '{ printf $3 }' | cut --delimiter=' '  -f1`

DoM=$((`date +%d` - DoC))

echo "$FILE last modified $DoM days ago"
DoC=date of creation
DoM=Date of modification

Not tested.

Vino
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0