HP OpenVMS Systems

ask the wizard
Content starts here

Sorting Directory Output by Date?

» close window

The Question is:

 
Any way to easily duplicate the unix function "ls -ltr" with the VMS directory
 command?  i.e., using the directory command, list the files in the order of
 oldest-to-most-recent.
 
Thx!!
 


The Answer is :

 
$ if p1 .eqs. "" then $ p1 = "*.*"
 
$ close /nolog outfile
$ open /write outfile x.x
$ loop:
$	file = f$search( p1 )
$	if file .eqs. "" then $ goto done
$	cdt = f$file_attributes( file, "CDT" )
$	cdt = f$cvtime( cdt, "COMPARISON" )
$	write outfile -
		cdt, -
		" ", -
		f$parse( file, , , "NAME" ),-
		f$parse( file, , , "TYPE" )
$ goto loop
$ done:
$ close outfile
$ sort x.x z.z /key = (position:1, size:22)
$ type z.z
$ delete x.x., z.z.
 

answer written or last revised on ( 26-NOV-2001 )

» close window