IITS Logo IITS Home Page spacer FeedBack Site Map Search IITS Concordia University Home Page
IITS Welcome General Information Help & Documentation IITS Services

IITS HelplineVMS Beginner's FAQ


[top] [previous] [next]

3. Files and Directories


How Do I...

1. How do I list the files in a directory?

Use the DIRECTORY command, which may be abbreviated to DIR.

Examples:

   $ DIR         List everything in the current directory.
   $ DIR DISK:[DIR1.SUBDIR1]
                        List everything in the specified directory.
   $ DIR/SIZE/OWNER/PROT FRED*.*
                        List all files begging with "FRED" and show
                        their size, who owns them, and what their protections
                        are.
   $ HELP DIR    More information on the DIRECTORY command.

[up]

2. How do I copy files?

Use the COPY command, or in some instances BACKUP or TYPE.

Examples:

   $ COPY file1 DISK:[DIR1.SUBDIR1]file2
                      Make a copy of file1 elsewhere, and call it file2.

   $ COPY *.TXT *.TEXT
                      Copy the most recent version of all files that 
                      have a .TXT extension, and give the copies .TEXT
                      extensions.

   $ BACKUP/VERIFY [.SUBDIR1...]*.*;* [.SUBDIR2...]
                      Copy the entire subdirectory tree from [.SUBDIR1]
                      down into another tree [.SUBDIR2].

   $ BACKUP/VERIFY [.SUBDIR1...]*.*;* []subdir1.bck/SAVE
                      Copy the entire subdirectory tree from [.SUBDIR1]
                      into a backup save set.  This could be transferred to
                      another machine and unpacked there.

   $ TYPE/OUT=file2 file1
                      Used for text files.  Copies file1 to file2, and
                      changes the file type from whatever it was to
                          File Organization: sequential
                          Record Format: variable
                          Record Attributes:  carriage-return
                      This can be useful before sorting files that
                      have stream-lf format - these often have invalid
                      longest record values, which complicates the SORT
                      command.

   $ HELP        More information on these commands.

[up]

3. How do I create files?

Many, many ways. If you want to create a text file you can use the CREATE command, enter the text on subsequent lines, and terminate with a ^Z. Using this method you can edit on the current line, but not fix typos on previous lines. Example:

   $ CREATE myfile.txt
   text line 1
   text line 2
   etc. etc. blah blah blah
   {^Z}
   $

For bettter control, use one of the many available text editor. However, to do so you must first learn how to use that editor. Example (editor commands not shown):

   $ EDIT myfile.txt

If you have DECwindows, the simplest "editor" is the Notepad program, which you may start from the Session Manager's Applications menu.

[up]

4. How do I delete files?

Use the DELETE command. Be careful with wildcards!!!!

   $ DELETE myfile.txt;  Delete the most recent version of myfile.txt.
   $ DELETE myfile.txt;* Delete all versions of myfile.txt.
   $ DELETE *.*;*        Delete everything in the current directory!!!!!!!
   $ HELP DELETE         More information on the DELETE command.

Note 1: Never delete MAIL*.MAI files using the DELETE command. Instead, go into MAIL and use the DELETE command in there.

Note 2: You can only delete files which have a D (delete) protection that enables you to do so. If you own it, you can set this with:

   $ SET FILE/PROTECTIO=O:RWED filename

Note 3: You cannot delete a directory that has anything left in it.

[up]

5. How do I delete older versions of files?

Use the PURGE command. This leaves the most recent version of a file, and removes older ones.

   $ PURGE             Remove older versions on all files in the current directory.
   $ PURGE/KEEP=3      Similar, but keep the 3 most recent versions.
   $ HELP PURGE        More information on the PURGE command.

[up]

6. How do I edit files?

Use a text editor. Several come standard with OpenVMS, and it is very common to see others that have been installed as well.

   $ Edit [/tpu] file   "Eve" Default OpenVMS text editor.
   $ Edit/EDT file      Used to be default OpenVMS text editor.
   $ Edit/TECO file     Older editor.
   $ note :== $SYS$SYSTEM:DECW$NOTEPAD
   $ note file          Requires DECwindows.  Simple GUI text editor.
   $ jed  file          Available for many platforms
   $ Pico file          Simple text editor, comes with PINE mailer.
   $ vi file            Standard Unix editor, comes with POSIX.
   $ EDIT/TPU/interface=DECWINDOWS  file
                          GUI interface for TPU
   $ nedit file         Requires DECWindows.  Simple GUI text editor.
   $ Xhtml file         Requires DECWindows.  Simple HTML editor. 

Note 1: Prior to OpenVMS 6.0 the default editor was EDT, since then, TPU.

Note 2: Virtually all editors have configuration files that they read when they start up. TPU has several. Here is a sample configuration file for EDT and instructions for using it.

First create an initialization file, here where it shows "^Z" in a line, it means two separate characters: {^} and {Z}.

   $ CREATE SYS$LOGIN:EDTINI.EDT
   !
   ! Set-up file for EDIT/EDT
   !
   ! Pieces from many places - no credits to anybody, sorry!!!
   !
   ! Suppress the bell or buzzer that signals errors
   ! SET QUIET
   !
   ! Define delimiters for the word entity
   SET ENTITY WORD '	 .,?!;:[]()><*-+=/\'
   !
   ! Define delimiters for the sentence entity
   SET ENTITY SENTENCE '. ?!'
   !
   ! Suppress line numbers in line mode
   SET NONUMBERS
   !
   ! Wrap full words to the next line at 75 characters
   SET WRAP 75
   !
   ! Key Definitions:
   ! 
   ! Change to the specified buffer
   DEFINE KEY GOLD B AS "EXT CHANGE =?'CHANGE TO BUFFER: '."
   !
   ! Change to the last current line in the previous buffer
   DEFINE KEY GOLD C AS "EXT CHANGE LAST."
   !
   ! Change the case of the current word
   DEFINE KEY GOLD D AS "+CHGCW."
   !
   ! Locate the last current line in the MAIN buffer
   DEFINE KEY GOLD G AS "EXT FIND=MAIN.."
   !
   ! Prompt for a buffer name and then locate the last current line
   ! in the specified buffer
   DEFINE KEY GOLD H AS "EXT FIND=?*'BUFFER:  '.."
   !
   ! Exit file
   !
   DEFINE KEY GOLD E AS "EXT EXIT."
   !
   ! Fill the text of the current paragraph to the right margin
   DEFINE KEY GOLD P AS "FILLPAR."
   !
   ! Quote file macro and key definition
   DEFINE MACRO QUOTE
   FIND BUFFER QUOTE
   insert;set quiet
   insert;change;er -l 9999(i>^Z -2l) ex
   insert;set noquiet
   FIND LAST
   DEFINE KEY GOLD Q AS "EXT QUOTE."
   !
   ! Shift screen left 1 tab (8 columns)
   DEFINE KEY GOLD L AS "SHL."
   !
   ! Append signature file macro and key definition
   DEFINE MACRO SIGNATURE
   FIND BUFFER SIGNATURE
   insert;change;desel er sel ^m ex
   insert;include sys$login:signature.txt end
   insert;change; -sr ex
   FIND LAST
   DEFINE KEY GOLD N AS "EXT SIGNATURE."
   !
   ! Shift screen right 1 tab (8 columns)
   DEFINE KEY GOLD R AS "SHR."
   !
   ! Replace all occurrences of the specified string in the 
   ! current buffer with the specified string
   DEFINE KEY GOLD S AS "EXT S/?*'REPLACE: '/?*'   WITH: '/WHOLE."
   !
   ! Transpose the two characters to the left of the cursor
   DEFINE KEY GOLD T AS "BACK C DC ADV C UNDC."
   !
   ! Write the current buffer to the specified file
   DEFINE KEY GOLD W AS "EXT WRITE ?*'WRITE TO FILE: '."
   !
   ! Include the specified file at the current line
   DEFINE KEY GOLD X AS "EXT INCLUDE ?*'INCLUDE FILE: '."
   !
   ! Include the specified file at the beginning of 
   ! the specified buffer
   DEFINE KEY GOLD Y AS "EXT INCLUDE ?*'INCLUDE FILE: ' =?*' BUFFER: ';FIND BEGIN."
   !
   ! Select editing mode: 
   SET MODE CHANGE
   {^Z}          Terminate entry of the file

Next, add the following line in your LOGIN.COM so that EDIT/EDT will automatically use this file. It will take effect next time you log in. (If ever you don't want to use it, start EDT with: EDIT/EDT/NOCOMMAND).

   $DEFINE EDTINI SYS$LOGIN:EDTINI.EDT

If you plan on appending a signature to mail messages, you must create the file SYS$LOGIN:SIGNATURE.TXT which is referenced by the GOLD N key.

Note 3: Most text editors use particularly keypad keys for certain purposes. Unfortunately, the keys on your keyboard may not be labeled to match the names used in the program. In particular, the {GOLD} key referred to in the EDT initialization file above is labeled {PF1} on most Digital keyboards, and {NumLOCK} on most PC and Macintosh keyboards.

It is usually, but not invariably, the leftmost button in the top row of the numeric keypad. To get a keypad map in EDT press the {HELP} button on your keyboard. If that fails, press the second to leftmost key on the top row of the numeric keypad.

Note 4: Most text editors need to know which type of terminal you are using. Be sure that the command

   $ SHOW TERMINAL     Show terminal configuration.

is consistent with the terminal/terminal emulator that you are using.

[up]

7. How do I move files?

If they are being moved on the same disk use RENAME. If they are going to another disk use COPY or BACKUP.

Examples:

   $ RENAME file1 [DIR1.SUBDIR1]file2
                      Rename file1 to file2 and put it in another 
                      directory on the same disk.
   $ COPY file1 DISK:[DIR1.SUBDIR1]file2
                      Make a copy of file1 elsewhere, and call it file2.
   $ BACKUP/VERIFY/DELETE file1 DISK:[DIR1.SUBDIR1]file2
                      Make a copy of file1 elsewhere, and call it file2.
                      Delete the original after first verifying the copy.
   $ HELP        More information on these commands.

[up]

8. How do I rename files?

See "How do I move files".

[up]

How do I view files' contents?

As usual, there are a couple of ways. Which you use depends mostly on what you want to know. Note that most editors have a /READ switch, or equivalent, which will prevent you from disturbing the file's contents while looking through it.

   $ TYPE [/page] filename     View contents on screen
   $ EDIT/READ filename        View contents on screen
   $ MOST [/page] filename     View contents on screen
   $ DIFFERENCES filename1 filename2
               Compare two files, look for differences.
   $ DUMP filename   Various views of data in the file.
   $ HELP            More information on these commands.

[up]

10. How do I print files' contents?

Use the PRINT command. All Print commands send a job to a print queue and then return control to the command line. Jobs wait in the print queue until the printer is free, and then they are sent to it. The logical symbol SYS$PRINT determines which print queue will be used unless it is overridden via a /QUEUE= qualifier on the command line.

Examples:

   $ PRINT filename     Print contents on default printer.
   $ PRINT/QUEUE=CPS_PS filename.ps  
                         Print (Postscript) contents on specified queue.
   $ PRINT/QUEUE=group_lw/FORM=PS_PLAIN filename.ps
                         Print (Postscript) contents on specified queue
                         using a Form.
   $ SHOW QUEUE/FORM    List all available print forms.
   $ SHOW QUEUE/BY_OWN  List queued print and batch jobs.
   $ DELETE/ENTRY=entry_number 
                         Oops, print job to wrong queue? Kill it this way.

[up]

How do I find a file by name, date, or other property?

There are two methods. Usually the DIRECTORY command has the appropriate qualifiers to find what you want. For really technical parameters you may have to use lexical functions inside a DCL procedure.

Examples:

   $ DIR/SINCE=YESTERDAY/BY_OWNER=[GRP_12,FRED]/MODIFIED
              All files in the current directory owned by FRED, who is
              a member of GRP_12, that have been modified since yesterday.

The following is a brief procedure that will find all files in the current directory that have file organization = sequential. (Silly example - most files are sequential!).

   $!first line of DCL procedure
   $top:
   $ file = f$search("*.*")
   $ if (file .eqs. "")then exit
   $ org = f$file_attributes(file,"ORG")
   $ if (org .eqs. "SEQ")then write sys$output file
   $ goto top
   $!last line of DCL procedure

[up]

12. How do I find files by their contents?

Use the SEARCH command.

Examples:

   $ SEARCH *.TXT FRED
              Find FRED, fred, Fred ,etc. in the most recent versions
              of any file with a TXT extension in the current directory.
   $ SEARCH/WINDOW=0/Exact/Match=and *.TXT "Fred","Jones"
              List the name of any file whose most recent version has
              Fred and Jones in the same line, and which as a TXT extension.
   $ HELP SEARCH More information on the SEARCH command.

[up]

13. How do I protect files from other users?

14. How do I share files with other users?

Set the file protection appropriately. There are four categories of users: System, Owner, Group, and World. For each group, you can specify what actions they can take regarding a particular file, these are Read, Write, Execute, and Delete. Here are some examples of how file protections are used:

   $ DIR/OWNER/PROTECTION Show who owns what with what protections.
   $ SET FILE/PROTECTION=(S:RWED,O:RWED,G:RE,W) filename
                Owner and system can do anything they want to this file,
                other group members can Read or Executate it, nobody else
                can do anything.  This is a common way to set protectins.
   $ SET FILE/PROTECTION=O:RWED filename
                Reset owner protections as shown, don't change others.

   $ HELP SPECIFY PROTECTION  More info on protections.

You can also allow and deny access by attaching an ACL (access control list) to a file. This method of protection is generally configured by the system manager rather than by a user.

[up]

15. How do I create a directory?

Use the CREATE/DIR command.
   $ CREATE/DIR [.SUBDIR1]
                Create a subdirectory named subdir1.dir in the
                current directory.

Note 1: Directories can only go eight levels deep.

Note 2: You must have appropriate Write access to the point where the directory is going in.

[up]

16. How do I delete a directory?

Change protections so that you can delete it. First delete everything that is in it. Then delete it.

Example:

   $ SET FILE/PROTECTION=O:RWED [.subdir1]*.*;*
   $ SET FILE/PROTECTION=O:RWED SUBDIR.DIR
   $ DELETE [.subdir1]*.*;*
   $ DELETE SUBDIR.DIR;

[up]

17. How do I rename a directory?

Use the RENAME command, just as you would for a regular file. However, first you must modify it so that O:D protection exists.

Example:

   $ SET FILE/PROTECTION=O:RWED subdir1.dir
   $ RENAME sudir1.dir [-]
                move the subdirectory one level up

[up]

18. How do I move to another directory?

Use the SET DEFAULT command. You can use either an absolute directory path, a relative directory path, or a logical name defined to be one of these.

The general form is:

   $ SET DEFAULT DEVICE:[DIRECTORY.SUBDIR]

Usually DEVICE: is a disk of some type, you can leave that piece off if you are moving around on the same disk.

Examples:

 
   $ SET DEFAULT  [.SUBDIR]          relative move down
   $ SET DEFAULT  [.SUBDIR1.SUBDIR2] relative move deeper
   $ SET DEFAULT  [-]                relative move up one level
   $ SET DEFAULT  DISK:[USERNAME]    absolute move
   $ DEFINE THERE DISK:[USERNAME]    define an absolute location
   $ SET DEFAULT THERE               move there
   $ DEFINE UP  [-]                  define a relative location
   $ SET DEFAULT UP                  move there

[up]

19. How do I identify the current directory?

Use the command SHOW DEFAULT.

Example:

   $ SHOW DEFAULT
   DISK:[USERNAME]

[up]


What is...

1. What are RMS attributes?

Most OpenVMS files are handled by a subsystem known as RMS, for Record Management Services. This part of the operating system allows OpenVMS programs to use optimized file formats for various applications, and yet still be able to read each others' files. Rarely do users need to concern themselves with RMS attributes, which describe the way the records (chunks of information within the file) are arranged. If it does come up, here are a few of the relevant commands:

  $ ANAL/RMS file
       See what the RMS attributes of file are.
  $ ANAL/RMS/FDL/OUTPUT=RMS  file
       Create a file called RMS.FDL that describes the records in file.
  $ CONVERT/FDL=RMS.FDL  file1 file2
       Convert the record structure in file1 to match that described in
       RMS.FDL and put the result in file2.
  $ SET FILE/ATTRIB=(LRL:1000) file
       Change one of the RMS attributes of file.
  $ EXCHANGE/NETWORK/FDL=RMS.FDL file1 file2
       Used primarily with files that are in stream-lf or fixed 512 byte
       record format (both common "binary" formats).  The exchange command
       will reestablish the original RMS attributes of the file, if they
       are available in an RMS.FDL file. 

Note 1:. The output of many DEC C programs are in stream-lf format. Such files have the unfortunate property that the Longest Record field is set to its maximum value of 32767. Normally this makes no difference, but it is a problem if you try to SORT such a file. The default action of the SORT utility is to allocate as much space for each record as the LRL value specifies. This works well for most files where each record is short. Here, however, the huge apparent record sizes make the sort exceedingly slow. There are a couple of workarounds:

         $ TYPE/OUT=NEW.TXT file.txt
                     Make another copy through type, which will 
                     correctly set the LRL, then sort the copy
         $ SET FILE/ATTRIBUTE=(LRL:30) file.txt
                     Set the LRL correctly, if you happen to know it.
                     Then sort the modified file.
         $ SORT/PROCESS=TAG/key=(pos:1,size:10) file.txt
                     Tell SORT to process the file differently - it will
                     only make space for the key region - 327 times smaller
                     than the declared "record" size.

[up]

2. What are creation, modification, and backup dates?

Creation date:         when the file was first made.
Modification date:     when the file was last modified.
Backup date:           when the file was last backed up.

[up]

[top] [previous] [next]


  [Back to Helpline Home Page]


Author: David Mathog
Credits: Rich Lafferty
Maintained by: helpline@alcor.concordia.ca
Last update: $Date: 1999/05/18 16:16:23 $ -- Rich Lafferty