Compare file modification date using tcsh built-ins

Compare file modification date using tcsh built-ins

Post by b.. » Tue, 10 Oct 2000 13:46:44



Is there any straightforward way to compare file modification dates
(i.e. which is older/newer) using tcsh built-ins?  I know ksh has the
"file1-nt" file2 and "file1-ot file2" operators for boolean expressions,
but I can't seem to find any relatively simple way of performing the
same comparision in tcsh, other than using sed/awk to extract the two
files' date fields from their "ls -l" listings and attempting to
lexographically compare two strings.

Thanks.
Ben West

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Compare file modification date using tcsh built-ins

Post by Ken Pizzi » Tue, 10 Oct 2000 14:36:09



>Is there any straightforward way to compare file modification dates
>(i.e. which is older/newer) using tcsh built-ins?

if (-M file1 > -M file2) echo "file1 is newer"

Quote:>but I can't seem to find any relatively simple way of performing the
>same comparision in tcsh, other than using sed/awk to extract the two
>files' date fields from their "ls -l" listings and attempting to
>lexographically compare two strings.

If you were using plain csh or a versioin of sh lacking -nt,
there's always "find":
  test -n `find file1 -newer file2 -print` && echo "file1 is newer"

                --Ken Pizzini

 
 
 

1. Comparing either files sizes or modification dates

Hi
In a nutshell,  I'm looking for a way to  copy a file only if it has
changed since the last copy was made.

I have some files to which I occasionally append some more information.
These files are "backuped" to another directory every time I logout. I'd
prefer to copy the files only if they've been changed, as this will save
me some time. The files are now ~900K. I believe that the
easiest/quickest way to do this would be to compare either the  size or
the modification dates of the two files. If they differ, then make the
backup copy. If not, log me out.
If it helps, I'm using tcsh and BSD 4.3.
Can anyone suggest a way to implement this?
Thanks.
Avram Walts

2. newbie question

3. comparing file modification dates

4. LISREL for Solaris

5. Help: Compare modification date of 2 files

6. using dump on smbfs mounted fs?

7. File modification date/time compare utility

8. are there any linux layer 3 link aggregation tools available?????

9. date/time of a file compare with current date/time

10. How to Compare File Date to Current Date

11. how to compare date of file to a fixed date?

12. How to compare file date and copy newer file ?

13. Comparing file modification times.