Delete z/OS data sets with a wildcard: DELETE generic names, MASK and ISPF 3.4
DELETE 'USER1.TEST.*' matches one qualifier and an exact qualifier count. Use DELETE 'USER1.TEST.**' MASK for any depth, or //D blocks in ISPF 3.4.
z/OS can delete many data sets with one command, but the wildcard rules depend on which form you use. DELETE is an Access Method Services command, and it takes the same names and keywords whether you type it in TSO or run it in an IDCAMS batch job. Check what a pattern matches before you run it: a deleted data set is gone unless your site has a backup of it.
Generic names: one asterisk, one qualifier
Without any keyword (the default is NOMASK), an asterisk replaces exactly one whole qualifier, and the name must have the same number of qualifiers as the data sets you want. IBM's example uses these four data sets:
AAA.BBB.CCC.DDD
AAA.BBB.CCZ.DDD
AAA.BBB.CCC.DDD.EEE
AAA.BBB.CCC
DELETE AAA.*deletes none of them: no data set has exactly two qualifiers.DELETE AAA.BBB.*deletes onlyAAA.BBB.CCC.DELETE AAA.BBB.*.DDDdeletes the first two.DELETE AAA.BBB.*.*andDELETE AAA.*.CCC.*fail withIDC3203I ITEM ... DOES NOT ADHERE TO RESTRICTIONS, because a generic name can have only one asterisk.
In TSO, put the name in single quotes to stop TSO from adding your prefix, for example DELETE 'USER1.TEST.*'. Quoting rules are in TSO commands.
MASK: any depth and partial qualifiers
With the MASK keyword, the name becomes a filter key, which allows:
**for any number of qualifiers.*inside a qualifier, such asTEMP*.%within a qualifier.
So this deletes USER1.TEST data sets at any depth:
DELETE 'USER1.TEST.**' MASK
Two rules come with MASK. You can give only one entry name. And in TSO the name is taken as written: TSO does not add your user ID prefix, so always give the full name.
In a batch job the same statement runs under IDCAMS:
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE USER1.TEST.** MASK
/*
Members of a PDS or PDSE
For a partitioned data set, the member name in parentheses can contain * and %:
DELETE 'USER1.TEST.CNTL(TEMP*)'
pdsname(*) or pdsname(**) deletes every member. For a PDS (not a PDSE), the (*) form also reinitializes the directory.
In ISPF option 3.4
The data set list (ISPF option 3.4) shows the data sets that match a name pattern, so you can see the list before deleting anything. Then:
- Type
Dnext to one data set to delete it. - To delete a run of data sets, type
//Din the command column of the first row and//on the last row, then press Enter. The command runs for every row in the block.
More on the list and its line commands is in ISPF navigation basics. If a delete fails because the data set is in use, see ISPF "Data set in use", who has it and what to do.
Related
- TSO commands
- ISPF navigation basics
- ISPF "Data set in use", who has it and what to do
- IKJ56700A ENTER JOBNAME CHARACTER(S) when you submit a job from ISPF or TSO
- Search all members of a data set in ISPF, SRCHFOR and SFE
Sources
- IBM z/OS 3.1 DFSMS Access Method Services Commands: DELETE required parameters (generic names, MASK filter keys, members, TSO prefix)
- IBM Support: IDCAMS DELETE using generic level qualifiers (asterisks) gives unexpected results
- IBM z/OS 3.1 ISPF User's Guide: Data set list utility line commands (block commands)