This is a text-only version of the following page on https://raymii.org: --- Title : File versioning and deleting on OpenVMS with DELETE and PURGE Author : Remy van Elst Date : 15-04-2018 URL : https://raymii.org/s/blog/File_versioning_and_deleting_on_OpenVMS.html Format : Markdown/HTML --- [![openvms][1]][2] (You can read all my OpenVMS articles by [clicking the picture above][2]) I'm now a few weeks into my OpenVMS adventure and my home folder on the [DECUS][3] system is quite cluttered with files. More specifically, with different versions of files, since OpenVMS by default has file versioning built in. 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 opinion so far on OpenVMS, but it does require maintenance to not have the disk get filled up fast. This article goes into the PURGE and DELETE commands which help you deal with file versioning and removal.

Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below:

I'm developing an open source monitoring app called Leaf Node Monitoring, for windows, linux & android. Go check it out!

Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.

You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $200 credit for 60 days. Spend $25 after your credit expires and I'll get $25!

### DIR flags My home folder [DECUS][3] is getting filled up with test files and other titbits. $ DIR /SIZE /OWNER /DATE /PROTECTION 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 can be removed. ### Look at the files with TYPE Using the `TYPE` command we can look at a file. Specify the full filename and a specific version number, otherwise if you omit the version you will see the last version: $ TYPE REMY.DAT;1 Twas brillig, and the slithy toves Did gyre and gimble in the wabe; All mimsy were the borogoves, And the mome raths outgrabe. hello Version 4: $ TYPE REMY.DAT;4 Twas brillig, and the slithy toves Did 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 shun The frumious Bandersnatch! The last version: $ TYPE REMY.DAT;8 Twas brillig, and the slithy toves Did 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 shun The 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 through The vorpal blade went snicker-snack! He left it dead, and with its head He 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 toves Did gyre and gimble in the wabe; All mimsy were the borogoves, And the mome raths outgrabe. (For those who do [not get][5] the reference). As you can see, the poem is finished in the last versions and the earlier versions are working copies that can be removed now that this poem is done. ### PURGE The [PURGE command][6] removes all but the highest version of a file. The `DELETE` command, which we will cover in the next section, only removes specific files 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 only the versions from after the specified time. Lets say I worked on a file the whole week but all versions that were created yesterday and today only contain formatting fixes, I would specify the `PURGE /SINCE=YESTERDAY $FILE`. The versions of earlier in the week which do contain changes I want to keep, will be saved that way. The opposite of that flags is `/BEFORE` flag. It removes all versions of a file before the given time. If I wanted to save all versions that I created yesterday and 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 a number 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 default no output is logged. So for my poem, to remove all versions but the last: $ PURGE /LOG REMY.DAT %PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;7 deleted (3 blocks) %PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;6 deleted (3 blocks) %PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;5 deleted (3 blocks) %PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;4 deleted (3 blocks) %PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;3 deleted (3 blocks) %PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;2 deleted (3 blocks) %PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;1 deleted (3 blocks) %PURGE-I-TOTAL, 7 files deleted (21 blocks) #### Create a directory with version limits Using the `/VERSION_LIMIT` flag when creating a folder limits the amount of versions that will be kept. By default it is unlimited. To create a folder named `THREE` where at max 3 versions are kept, use the following command: $ CREATE /DIRECTORY /VERSION_LIMIT=3 [.THREE] $ SET DEF [.THREE] I have edited my `REMY.DAT` file three times: $ DIR Directory DSA3:[DECUSERVE_USER.EXAMPLE.THREE] REMY.DAT;3 REMY.DAT;2 REMY.DAT;1 Now after a new edit, version 1 of the file will be gone: $ DIR Directory DSA3:[DECUSERVE_USER.EXAMPLE.THREE] REMY.DAT;4 REMY.DAT;3 REMY.DAT;2 Total 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 last versions, I would use the following command: $ PURGE /LOG /KEEP=2 REMY.DAT %PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE.THREE]REMY.DAT;2 deleted (3 blocks) Let's check if versions 3 and 4 are still there: $ DIR Directory DSA3:[DECUSERVE_USER.EXAMPLE.THREE] REMY.DAT;4 REMY.DAT;3 Total of 2 files. ### DELETE You can read most of my delete adventures [here when I tried to remove a folder][7]. [Reading the documentation][8] on `DELETE`, the same usefull flags like `/BEFORE` and `/SINCE` can be used. However, they will not remove previous versions, 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 marking the location as usable again. The `/ERASE` flag also overwrites the files with something so that the data actually is not on the disk and not recoverable anymore: /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: /TREE Recursively deletes all files and sub directories excluding the parent directory. As said, `DELETE` requires a version number. Just trying to delete my `REMY.DAT` file will fail: $ DELETE REMY.DAT %DELETE-E-DELVER, explicit version number or wild card required When a version is specified it does work: $ DELETE /LOG REMY.DAT;4 %DELETE-I-FILDEL, DSA3:[DECUSERVE_USER.EXAMPLE.THREE]REMY.DAT;4 deleted (3 blocks) ### Conclusion In this article we covered the different ways to cleanup versions of files, in the other article we covered the removal of directories. We also know now how to create a folder with limits on the amount of versions that are kept. [1]: https://raymii.org/s/inc/img/ovmsdec.png [2]: https://raymii.org/s/tags/openvms.html [3]: http://decus.org [4]: https://www.digitalocean.com/?refcode=7435ae6b8212 [5]: https://en.wikipedia.org/wiki/Jabberwocky [6]: http://web.archive.org/web/20180415125506/http://h41379.www4.hpe.com/doc/84final/9996/9996pro_159.html [7]: https://raymii.org/s/blog/Delete_a_directory_in_OpenVMS.html [8]: http://web.archive.org/web/20180415131447/http://h41379.www4.hpe.com/doc/84final/9996/9996pro_50.html --- License: All the text on this website is free as in freedom unless stated otherwise. This means you can use it in any way you want, you can copy it, change it the way you like and republish it, as long as you release the (modified) content under the same license to give others the same freedoms you've got and place my name and a link to this site with the article as source. This site uses Google Analytics for statistics and Google Adwords for advertisements. You are tracked and Google knows everything about you. Use an adblocker like ublock-origin if you don't want it. All the code on this website is licensed under the GNU GPL v3 license unless already licensed under a license which does not allows this form of licensing or if another license is stated on that page / in that software: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Just to be clear, the information on this website is for meant for educational purposes and you use it at your own risk. I do not take responsibility if you screw something up. Use common sense, do not 'rm -rf /' as root for example. If you have any questions then do not hesitate to contact me. See https://raymii.org/s/static/About.html for details.