Compering file time stamps

Compering file time stamps

Post by Vegard Bakk » Fri, 06 Dec 1996 04:00:00



I want to find out which of two files that is the newest.
What is the esaiest way to do this?
I'm using HP-UX 10.10, and preferably ksh.

Vegard

--
                         Vegard Bakke,
                  Kirkegata 9, 3600 Kongsberg

  "My spelling is Wobbly.  It's good spelling but it Wobbles,
and the letters get in the wrong places." A. A. Milne (1882-1958)

 
 
 

Compering file time stamps

Post by Mark D. Stoc » Sat, 07 Dec 1996 04:00:00



> I want to find out which of two files that is the newest.
> What is the esaiest way to do this?
> I'm using HP-UX 10.10, and preferably ksh.

Try:
        ls -t file1 file2 |head -1

Hope that helps,
--

Mark.

+-------------------------------------------------------------------------+
|Mark D. Stock - The West Solutions Group           http://www.west.co.za |
|                            The Informix FAQ is at http://www.iiug.org   |

|Tel:   +27 11 803 2151  |If it doesn't work... force it!                 |
|Fax:   +27 11 803 2189  |If it breaks... it needed replacing anyway!     |
|Cell:  +27 83 250 2325  |Well, that's how I code anyway!                 |
+------------------------+------------------------------------------------+

 
 
 

Compering file time stamps

Post by Chet Ram » Sat, 07 Dec 1996 04:00:00




Quote:>I want to find out which of two files that is the newest.
>What is the esaiest way to do this?
>I'm using HP-UX 10.10, and preferably ksh.

if [ file1 -nt file2 ]; then
        newer=file1
else
        newer=file2
fi
--
``The lyf so short, the craft so long to lerne.'' - Chaucer


 
 
 

Compering file time stamps

Post by Brian Duan » Sat, 07 Dec 1996 04:00:00



> I want to find out which of two files that is the newest.
> What is the esaiest way to do this?
> I'm using HP-UX 10.10, and preferably ksh.

ksh has a built-in to do this:

test file1 -nt file2    # is file1 newer than file2?

--

 
 
 

Compering file time stamps

Post by Brian S Hil » Sat, 07 Dec 1996 04:00:00



: : I want to find out which of two files that is the newest.
: : What is the esaiest way to do this?
: : I'm using HP-UX 10.10, and preferably ksh.
: Try:
:       ls -t file1 file2 |head -1

Also,

find file1 -newer file2 -print

(One less process; null output means file2 is newer.)

-Brian
--
   ,---.     ,---.     ,---.     ,---.     ,---.     ,---.     ,---.  
  /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \  

__,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.__

 
 
 

Compering file time stamps

Post by Eric van der Me » Sun, 08 Dec 1996 04:00:00




> I want to find out which of two files that is the newest.
> What is the esaiest way to do this?
> I'm using HP-UX 10.10, and preferably ksh.

> Vegard

> --
>                          Vegard Bakke,
>                   Kirkegata 9, 3600 Kongsberg

>   "My spelling is Wobbly.  It's good spelling but it Wobbles,
> and the letters get in the wrong places." A. A. Milne (1882-1958)

You might try:

   if [[ file1 -nt file2 ]]; then
      # first is newest
   else
      # second is newest
   fi

Hope this helps,

Eric.

 
 
 

Compering file time stamps

Post by Brian Duan » Sun, 08 Dec 1996 04:00:00





> : : I want to find out which of two files that is the newest.
> : : What is the esaiest way to do this?
> : : I'm using HP-UX 10.10, and preferably ksh.
> : Try:
> :       ls -t file1 file2 |head -1

> Also,

> find file1 -newer file2 -print

> (One less process; null output means file2 is newer.)

Maybe not - could be same age :-)

if [ file1 -nt file2 ] ;then echo file1 newer ;fi

No processes - all ksh built-in

--

 
 
 

Compering file time stamps

Post by Mark D. Stoc » Wed, 11 Dec 1996 04:00:00





> : : I want to find out which of two files that is the newest.
> : : What is the esaiest way to do this?
> : : I'm using HP-UX 10.10, and preferably ksh.
> : Try:
> :       ls -t file1 file2 |head -1

> Also,

> find file1 -newer file2 -print

> (One less process; null output means file2 is newer.)

I just find 'find' a tad slow, if you know what I mean. ;-)
--

Mark.

+-------------------------------------------------------------------------+
|Mark D. Stock - The West Solutions Group           http://www.west.co.za |
|                            The Informix FAQ is at http://www.iiug.org   |

|Tel:   +27 11 803 2151  |If it doesn't work... force it!                 |
|Fax:   +27 11 803 2189  |If it breaks... it needed replacing anyway!     |
|Cell:  +27 83 250 2325  |Well, that's how I code anyway!                 |
+------------------------+------------------------------------------------+

 
 
 

Compering file time stamps

Post by Andy Barfo » Wed, 11 Dec 1996 04:00:00



> I want to find out which of two files that is the newest.
> What is the esaiest way to do this?
> I'm using HP-UX 10.10, and preferably ksh

Yet another way:
        if [[ file1 -nt file2 ]]; then
        ...
"-nt" means "newer than"

-andy

 
 
 

Compering file time stamps

Post by Michael Web » Thu, 12 Dec 1996 04:00:00



>I want to find out which of two files that is the newest.
>What is the esaiest way to do this?
>I'm using HP-UX 10.10, and preferably ksh.

HP's ksh should support "test file1 -ot file2" and "test file1 -nt file2"
which is "older than" and "newer than" ...

 /Byte
--
Michael Weber, Weberkoppel 35, 23562 Luebeck, Germany, ++49-451/595864 (Q)

Ancient Astronaut Society, Internet Project: http://www.access.ch/aas/

 
 
 

1. Time discrepancy between Linux and DOS time stamps for same file

When I look at the time stamp on a dos file using ls in Linux, it reports
a different time than DOS reports for the same file using dir.

This is for the /dosc partition mounted under Linux as a type msdos partition.

The time differential seems to be about 10 1/2 hours; where Linux thinks the
file is 10 1/2 hours older than the DOS time.

Does anyone know a fix or reason for this?

Thanks,


--

2. Shouks I switch II + where to get it

3. File Time Stamp

4. NFS-Bootdisk

5. Changing File Modified Time/Date Stamp

6. Accessing Sun UFS File System

7. File Mode and Time Stamp

8. Linux

9. How to obtain the age of a file (epoch time stamp)

10. How to compare file time stamps in condition statements?

11. file name by time stamps

12. Finding new files (create after a time stamp)

13. Changing File Modified Time/Date Stamp