Skip to main content Logo (IEC resistor symbol)logo

Quis custodiet ipsos custodes?
Home | About | All pages | RSS Feed | Gopher

File versioning and deleting on OpenVMS with DELETE and PURGE

Published: 15-04-2018 | Author: Remy van Elst | Text only version of this article

Table of Contents


(You can read all my OpenVMS articles by clicking the picture above)

I'm now a few weeks into my OpenVMS adventure and my home folder on theDECUS system is quite cluttered with files. More specifically, withdifferent versions of files, since OpenVMS by default has file versioning builtin. This means that when you edit a file, or copy a file over an existing file,the old file is not overwritten but a new file with a new version is written.The old file still is there. This is one of the best things in my humble opinionso far on OpenVMS, but it does require maintenance to not have the disk getfilled up fast. This article goes into the PURGE and DELETE commands which helpyou deal with file versioning and removal.

If you like this article, consider sponsoring me by trying out a Digital OceanVPS. With this link you'll get $100 credit for 60 days). (referral link)

DIR flags

My home folder DECUS is getting filled up with test files and othertitbits.


Look at those fancy new flags I found to get more information out of DIR:

Directory DSA3:[DECUSERVE_USER.EXAMPLE]$MAIN.TPU$JOURNAL;1                              1  28-MAR-2018 07:42:31.09  [EXAMPLE]                           (RWED,RWED,,).VIMINFO;1                   10  15-APR-2018 08:39:53.81  [EXAMPLE]                           (RWED,RWED,,)A.;1                          1   8-APR-2018 05:30:44.16  [EXAMPLE]                           (RWED,RWED,,)ICREATEDAFOLDERYAY.DIR;1                              1  28-MAR-2018 08:22:18.41  [EXAMPLE]                           (RWE,RWE,,)LOGIN.COM;2                   2   8-APR-2018 06:02:12.72  [EXAMPLE]                           (RWED,RWED,,)LOGIN.COM;1                   2   1-MAR-2018 10:10:32.12  [EXAMPLE]                           (RWED,RWED,,)LOGIN_COM.TPU$JOURNAL;1                              1   8-APR-2018 06:00:38.04  [EXAMPLE]                           (RWED,RWED,,)MAIL.DIR;1                    1   8-APR-2018 16:28:23.24  [EXAMPLE]                           (RWE,RWE,,)NOTES$NOTEBOOK.NOTE;1                             51   1-MAR-2018 09:56:04.63  [DECUSERVE]                      (RWE,RWE,,)RAYMII.DIR;1                  1  31-MAR-2018 14:29:02.15  [EXAMPLE]                           (RWE,RWE,,)REMY.DAT;8                    1  15-APR-2018 08:39:53.79  [EXAMPLE]                           (RWED,RWED,,)REMY.DAT;7                    1  15-APR-2018 08:39:47.90  [EXAMPLE]                           (RWED,RWED,,)REMY.DAT;6                    1  15-APR-2018 08:39:12.75  [EXAMPLE]                           (RWED,RWED,,)REMY.DAT;5                    1  15-APR-2018 08:39:05.02  [EXAMPLE]                           (RWED,RWED,,)REMY.DAT;4                    1  15-APR-2018 08:38:44.90  [EXAMPLE]                           (RWED,RWED,,)REMY.DAT;3                    1  31-MAR-2018 14:44:31.08  [EXAMPLE]                           (RWED,RWED,,)REMY.DAT;2                    1  28-MAR-2018 07:52:19.04  [EXAMPLE]                           (RWED,RWED,,)REMY.DAT;1                    1  28-MAR-2018 07:48:21.66  [EXAMPLE]                           (RWED,RWED,,)SSH.DIR;1                     1   3-APR-2018 15:27:07.45  [EXAMPLE]                           (RWE,RWE,,)SSH2.DIR;1                    1   3-APR-2018 13:16:46.97  [EXAMPLE]                           (RWE,RWE,,)SSH3.DIR;1                    1   5-APR-2018 13:10:06.94  [EXAMPLE]                           (RWE,RWE,,)WWW.DIR;1                     1  28-MAR-2018 07:43:47.18  [EXAMPLE]                           (RWE,RWE,,RE)Total of 22 files, 83 blocks.

Lets focus on the REMY.DAT file, that has 8 versions and all the old ones canbe removed.

Look at the files with TYPE

Using the TYPE command we can look at a file. Specify the full filename and aspecific version number, otherwise if you omit the version you will see the lastversion:

 $ TYPE REMY.DAT;1Twas brillig, and the slithy tovesDid gyre and gimble in the wabe;All mimsy were the borogoves,And the mome raths outgrabe.hello

Version 4:

 $ TYPE REMY.DAT;4Twas brillig, and the slithy tovesDid gyre and gimble in the wabe;All mimsy were the borogoves,And the mome raths outgrabe.Beware the Jabberwock, my son!The jaws that bite, the claws that catch!Beware the Jubjub bird, and shunThe frumious Bandersnatch!

The last version:

 $ TYPE REMY.DAT;8Twas brillig, and the slithy tovesDid gyre and gimble in the wabe;All mimsy were the borogoves,And the mome raths outgrabe.Beware the Jabberwock, my son!The jaws that bite, the claws that catch!Beware the Jubjub bird, and shunThe frumious Bandersnatch!He took his vorpal sword in hand:Long time the manxome foe he sought-So rested he by the Tumtum tree,And stood awhile in thought.And as in uffish thought he stood,The Jabberwock, with eyes of flame,Came whiffling through the tulgey wood,And burbled as it came!One, two! One, two! And through and throughThe vorpal blade went snicker-snack!He left it dead, and with its headHe went galumphing back.And hast thou slain the Jabberwock?Come to my arms, my beamish boy!O frabjous day! Callooh! Callay!He chortled in his joy.Twas brillig, and the slithy tovesDid gyre and gimble in the wabe;All mimsy were the borogoves,And the mome raths outgrabe.

(For those who do not get the reference).

As you can see, the poem is finished in the last versions and the earlierversions are working copies that can be removed now that this poem is done.


The PURGE command removes all but the highest version of a file. TheDELETE command, which we will cover in the next section, only removes specificfiles and it requires you to specify a version number as well.

The PURGE command is therefore usefull to clean up old versions of a file.There are a few usefull flags, for example the /SINCE flag. It removes onlythe versions from after the specified time. Lets say I worked on a file thewhole week but all versions that were created yesterday and today only containformatting fixes, I would specify the PURGE /SINCE=YESTERDAY $FILE. Theversions of earlier in the week which do contain changes I want to keep, will besaved that way.

The opposite of that flags is /BEFORE flag. It removes all versions of a filebefore the given time. If I wanted to save all versions that I created yesterdayand today, but remove all earlier versions, the command would be PURGE/BEFORE=YESTERDAY $FILE.

If you do want to keep some versions, the /KEEP flag allows you to specify anumber of versions to keep. To keep the 5 last versions, specify /KEEP=5.

The /LOG flag shows you the result, thus which files were removed. By defaultno output is logged.

So for my poem, to remove all versions but the last:


Create a directory with version limits

Using the /VERSION_LIMIT flag when creating a folder limits the amount ofversions that will be kept. By default it is unlimited. To create a folder namedTHREE where at max 3 versions are kept, use the following command:


I have edited my REMY.DAT file three times:


Now after a new edit, version 1 of the file will be gone:

 $ DIRDirectory DSA3:[DECUSERVE_USER.EXAMPLE.THREE]REMY.DAT;4          REMY.DAT;3          REMY.DAT;2Total of 3 files.

To create a folder without versioning, specify /VERSION_LIMIT=1.

Combining that with the previous section, if I wanted to keep the two lastversions, I would use the following command:


Let's check if versions 3 and 4 are still there:

 $ DIRDirectory DSA3:[DECUSERVE_USER.EXAMPLE.THREE]REMY.DAT;4          REMY.DAT;3Total of 2 files.


You can read most of my delete adventures here when I tried to remove afolder.

Reading the documentation on DELETE, the same usefull flags like/BEFORE and /SINCE can be used. However, they will not remove previousversions, but all previous files and must be used with wildcards:

/BEFORE[=time]Selects only those files dated prior to the specified time. You can specify time as absolute time, as a combination of absolute and delta times, or as one of the following keywords: BOOT, LOGIN, TODAY (default), TOMORROW, or YESTERDAY.

Even back then they were already not actually removing a file, but just markingthe location as usable again. The /ERASE flag also overwrites the files withsomething so that the data actually is not on the disk and not recoverableanymore:

/ERASE/NOERASE (default)When you delete a file, the area in which the file was stored is returned to the system for future use. The data that was stored in that location still exists in the system until new data is written over it. When you specify the /ERASE qualifier, the storage location is overwritten with a system specified pattern so that the data no longer exists.  

The rm -rf alternative for OpenVMS seems to be the /TREE flag:

/TREERecursively deletes all files and sub directories excluding the parent directory.

As said, DELETE requires a version number. Just trying to delete my REMY.DATfile will fail:

 $ DELETE REMY.DAT%DELETE-E-DELVER, explicit version number or wild card required

When a version is specified it does work:



In this article we covered the different ways to cleanup versions of files, inthe other article we covered the removal of directories.

We also know now how to create a folder with limits on the amount of versionsthat are kept.

Tags: alpha, blog, dec, decus, itanium, openvms, pdp, simh, vax, vms