- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- How to sort all files by date in ascending order
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-22-2010 01:19 AM
тАО06-22-2010 01:19 AM
How to sort all files by date in ascending order
Would like to dir and list all the files by date. However seems like the sorting is on alphabetical order instead of the date.
dir *.exe /date
The date is mixed up, not sorting from the oldest to the current 1.
Is there any command that could help? Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-22-2010 01:46 AM
тАО06-22-2010 01:46 AM
Re: How to sort all files by date in ascending order
It is a multi-step process:
- produce the list of all files in a format that can be sorted (e.g., DIRECTORY/BRIEF/NOHEAD/NOTRAIL/DATE/OUTPUT=
- the resulting output will be a file of two-line entries; reformat the entries into single lines (my preference would be "date" followed by "filename")
- use SORT to sort the resulting file.
This process is far simpler if one temporarily sets the process' time/date format to a collating friendly format (if memory recalls correctly, details are in Section 27.6 of the Programming Concepts manual, available from the HP OpenVMS WWW site at http://www.hp.com/go/openvms.
One could also do this using pipes. My description assumes no particular version of OpenVMS.
- Bob Gezelter, http://www.rlgsc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-22-2010 02:11 AM
тАО06-22-2010 02:11 AM
Re: How to sort all files by date in ascending order
Yes, output of $ DIR command is based on the alphabetical order. And you need to write the script to meet your requirement.
Regards,
Ketan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-22-2010 02:50 AM
тАО06-22-2010 02:50 AM
Re: How to sort all files by date in ascending order
Try using DIRE/DATE=CREATED will have a display in serial order then using the output we can sort it out using script.
Regards,
Shahina
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-22-2010 03:07 AM
тАО06-22-2010 03:07 AM
Re: How to sort all files by date in ascending order
Results are in one of my DCL procedures:
http://wwwvms.mppmu.mpg.de/vms$common/com/dir_by_date.com
or
http://wwwvms.mppmu.mpg.de/vms$common/com/dir_by_date2.com
OR
look for QDSB* in
http://www.quadratrix.be/downloads
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-22-2010 03:14 AM
тАО06-22-2010 03:14 AM
Re: How to sort all files by date in ascending order
google: +openvms +date +sorted +directory optionally add: +site:itrc.hp.com
finds:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1190275
which reads..
You can tell sort a magic collating sequence to get the (english) months right.
See old topic (1996) in c.o.v
http://groups.google.com/group/comp.os.vms/search?hl=en&group=comp.os.vms&q=hein+collating_sequence
Or more recently here:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1095459
And finally, here is a perl 'one liner':
$ perl -e "while (<*.tmp;*>) { $f{$_}=-M } foreach $x (sort {$f{$b}<=>$f{$a}} keys %f){ print qq($x\n)}"
That was sorted on modification date, new to old. For new to old switch the $a and $b around.
Cheers,
Hein.
$ pipe dir/col=1/wid=fil=55/nohead/notrai/date | sort/spec=sort_by_date.sort sys$pipe sys$output
----------- sort_by_date.sort -----------
/collating_sequence=
(
sequence=("AN","EB","AR","PR","AY","UN","UL","UG","EP","CT","OV","EC",
" ","0"-"9"),
fold
)
! second and third letters of each month
/field=(name=year,pos:65,size:4)
/field=(name=month,pos:62,size:2) ! start at SECOND letter
/field=(name=day,pos:58,size:2)
/field=(name=time,pos:70,size:11)
! assume "14-OCT-1986 09:14:46.00" at position 58
/key=(year,descending)
/key=(month,descending)
/key=(day,descending)
/key=(time,descending)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-22-2010 03:47 AM
тАО06-22-2010 03:47 AM
Re: How to sort all files by date in ascending order
http://www.quadratrix.be/qdsb.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-22-2010 04:20 AM
тАО06-22-2010 04:20 AM
Re: How to sort all files by date in ascending order
>> However seems like the sorting is on alphabetical order instead of the date.
Yes, the DIR command always displays the files in the directory in
alphabetical order of filenames. This is the behavior in VMS.
Even if you give a selection criteria such as "/SINCE" or "/BEFORE",
the names would eventually get displayed in alphabetical order of filenames
itself.
>> Is there any command that could help?
No direct command.
As others have suggested, you need to write a command procedure for this.
it would be 2 step procedure.
* First step would be to get the output of DIR command with "/SINCE" or
"/BEFORE" qualifier. Take this output to a file.
* Second step would be to sort the output file based on the date.
Hope this helps.
Regards,
Murali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-22-2010 04:37 AM
тАО06-22-2010 04:37 AM
Re: How to sort all files by date in ascending order
All procedures using the output of a DIRECTORY command for sorting have a problem if file-specifications are longer than the space available in the DIR output (the /width=filename=n).
Directory the wraps the rest of the output to a second line, and sort will be confused.
My dir_by_date2.com avoids this trap (but the output is a bit unusual with the date in front of the file-name).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-22-2010 04:43 AM
тАО06-22-2010 04:43 AM
Re: How to sort all files by date in ascending order
ls -lt
ls -ltr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-22-2010 05:02 AM
тАО06-22-2010 05:02 AM
Re: How to sort all files by date in ascending order
>> Directory the wraps the rest of the output to a second line,
>> and sort will be confused.
Thats a good point.
The parsing routine has to consider this scenario that a filename can get
displayed in multiple lines and needs to be able to handle that.
Also another thing to consider (may not be in this case),
When parsing a line of DIR output, program cannot check directly for any
known characters like "(" and so on. i.e. it cannot rely on the fact that
the "(" ... is a delimiter. These characters can be a part of the filename
(ODS5 filenames allows that). The program needs to be take care of this.
Regards,
Murali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2010 07:29 PM
тАО06-23-2010 07:29 PM
Re: How to sort all files by date in ascending order
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2010 07:36 PM
тАО06-23-2010 07:36 PM
Re: How to sort all files by date in ascending order
>> One day maybe HP will add a /SORT=x capability to $ DIRECTORY
Let me know if there is any business requirement for availability of this feature.
I can add this to the wish list along with the supporting text.
Regards,
Murali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2010 09:52 PM
тАО06-23-2010 09:52 PM
Re: How to sort all files by date in ascending order
> One day maybe HP will add a /SORT=x
> capability to $ DIRECTORY and let us sort
> by filesize, by any date and by (what
> else?), of course with the default being
> by filename ... but it's not available
> yet.
It's already there. Check out QDSB (as Joseph already pointed out) at
http://www.quadratrix.be/qdsb.html
Regards,
Kris (aka Qkcl)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2010 10:11 PM
тАО06-23-2010 10:11 PM
Re: How to sort all files by date in ascending order
>> It's already there. Check out QDSB (as Joseph already pointed out) at
>> http://www.quadratrix.be/qdsb.html
Yes, thats right. I missed seeing this before.
I did a quick instal and checked it out.
It provides the feature which sorts and displays entries in the directory based
on name, creation date, type and so on.
Nice tool.
Jess,
The QDSB tool gives you the feature that you are looking for.
In case you have not already started using it, you can start now.
Regards,
Murali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2010 10:55 PM
тАО06-23-2010 10:55 PM
Re: How to sort all files by date in ascending order
Even I have also tried this tool.
This is really a nice tool. Thanks for letting us to know about such a good tool.
Regards,
Ketan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 12:04 AM
тАО06-24-2010 12:04 AM
Re: How to sort all files by date in ascending order
My above reply to use GNV ls -lt, ls -ltr means:
either define
bash :== $GNU:[bin]bash (GNV$GNU:[BIN] for newer versions of GNV)
or have GNU:[bin] in Your DCL$path logical list.
Then define the DCL ls command as
ls == "bash -c ""ls"
(sic ! the missing double quote at the end is intended).
Through the "bash -c" call ls works with (unix-style) wildcards, while a direct "ls := $GNU:[bin]ls" will not work with wildcards.
In a similar fashion other bash shell commands can be defined:
$ rm == "bash -c ""rm"
$ cat == "bash -c ""cat"
$ gdiff == "bash -c ""diff"
$ grep == "bash -c ""grep"
$ egrep == "bash -c ""egrep"
$ fgrep == "bash -c ""fgrep"
$ touch == "bash -c ""touch"
"cd" cannot be used like this, because it is a bash internal command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 11:55 AM
тАО06-24-2010 11:55 AM
Re: How to sort all files by date in ascending order
Sorting DIRECTORY by modification date
[posted to comp.os.vms by Peter Weaver (WeaverConsultingServices@sympatico.ca) on 29-APR-2004]
$ ASSIGN LIB$DATE_FORMAT_037,-
LIB$TIME_FORMAT_001 -
LIB$DT_FORMAT/USER_MODE
$! Ignore any DIR symbols
$ directx -
/date=modified-
/width=(file:80,display:132)-
/out=out.txt
$ sort out.txt -
/key=(pos:83,siz:22) tt:
should do it as long as someone with privileges did the @SYS$STARTUP:LIB$DT_STARTUP first.
Consultant
Wipro Technologies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 12:13 PM
тАО06-24-2010 12:13 PM
Re: How to sort all files by date in ascending order
$ bash
ls -tla
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2010 07:20 AM
тАО06-28-2010 07:20 AM
Re: How to sort all files by date in ascending order
I hope you are using (might have become expert :)) the QDSB tool by now.
Also, Refer the following link which says how you can thank the forum -
http://forums11.itrc.hp.com/service/forums/helptips.do?#28
Regards,
Murali