Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
HP.com home

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

 

** About PDF files: The PDF files on this Web site can be read online or printed using Adobe® Acrobat® Reader. If you do not have this software installed on your system, you may download it from Adobe's Web site
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2008 Hewlett-Packard Development Company, L.P.