Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto detection of date of a file

Status
Not open for further replies.

kaul01

Programmer
May 16, 2001
2
GB
Hello all ,

I am facing a problem as follows :
If a shell script is written which ought to detect the
Date of a File( any file) and see if it is greater/less
than the System Date then how can this be done i.e for eg
If today is Monday and the shell script is run by the Unix scheduler then how does it(shell script) check whether a file in a particular directory has a date greater than Last Friday(say).

Thanks
Ajay
 
ls -al filename | cat ..... returns the date of the file
date | cat gets the symbols you need
and the other is up to you ;)

Good luck ;)
 
if you have 'awk' in your system you can try
the following.

file_date = ls -la $1 | awk '{ printf "%s %s", $6 $7 }'
This will put the day and date in the variable
"file_date". For example if the date of the file is
May 25, file_date will contain "May 25".

Now you have what you want, you can write a simple shell
script to compare this date against your date last friday
and print out the results.

:-D
abp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top