3

I want to remove lots of temporary PS datasets with dataset name like MYTEST.**, but still can't find an easy way to handle the task.
I meant to use a Shell command below to remove them

  cat "//'dataset.list'"| xargs -I '{}' tsocmd "delete '{}'"

However, first I have to save the dataset list into a PS dataset or Unix file. In Unix, we can redirect output of ls command into a text file: "ls MYTEST.* > dslist", but on TSO or ISPF panel, seems no simple command to do that.

Anyone has any clue on this? Your comment would be appreciated.

thinkhy
  • 923
  • 13
  • 25
  • http://pic.dhe.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.idak100/amsr11.htm. If you are going with your one-liner, you have no record of what has happened, unless you make it so. Anyway, rather than an update to the question, can you post it as an Answer, and then Accept it when you can? Easier for someone else to consider making use of it. – Bill Woodger Jul 22 '14 at 07:40

4 Answers4

2

Update - The IDCAMS DELETE command has had the MASK operand for a while. You use it like:

DELETE 'MYTEST.**' MASK

Documentation for z/OS 2.1 is here.

Tony
  • 1,221
  • 2
  • 12
  • 25
  • I didn't know about the MASK option - that's what I get for not reading the docs on DELETE for 20+ years! – mike Jun 21 '23 at 03:48
  • I think this is the best answer. Presumably it should be lightening fast and you could wrap it around tsocmd if you wanted to run it from UNIX System Services. – mike Jun 21 '23 at 03:50
  • If you have Z Open Automation Utilities installed - I think it's comparable and perhaps also syntactically a bit easier but it isn't part of the OS – mike Jun 21 '23 at 03:52
1

Rexx ISPF option is probably the easiest and can be used in the future, but options include:

  • Use the save command in ispf 3.4 to save to a file, then use a rexx program on the file created by the save command

  • listcat command, in particular

    listcat lvl(MYTEST) ofile(ddname)

    then write a rexx program to do the actual delete

  • Alternatively you can use the ISPF services LMDINIT, LMDLISTY & LMDFREE in a rexx program running under ISPF i.e.

       /* Rexx ispf program to process datasets */
       Address ispexec 
       "LMDINIT LISTID(lidv)  LEVEL(MYTEST)"
       "LMDLIST LISTID("lidv") OPTION(list) dataset(dsvar) stats(yes)"
       do while rc = 0
          /* Delete or whatever */
       end
       "LMDFREE LISTID("lidv")"

For all these methods you need to fully qualify the first High level qualifier.


Learning what Rexx / ISPF will serve you into the future. In the ISPF Editor, you can use the model command to get Templates / information for all the ISPF commands:

 Command ====> Model LMDINIT 

will add a template for the lmdinit command. There are templates for rexx, cobol, pl1, ISPF-panels, ISPF-skeletons messages etc.

Bruce Martin
  • 10,358
  • 1
  • 27
  • 38
1

You can use the ZOAU drm utility with wildcards. It will do exactly what you want.

drm 'test01.*.txt'
drm 'test??.proj23.*'
drm -f ibmuser.my.jcl
drm 'ibmuser.proj22.*' 'ibmuser.proj23.*'
Anthony Giorgio
  • 1,844
  • 1
  • 15
  • 17
0

Thanks Bruce for the comprehensive answer. According to Bruce's tips, I just worked out a one-line Shell command as below:

 tsocmd "listcat lvl(MYTEST) " | grep -E "MYTEST(\..+)+" | cut -d' ' -f3 | xargs -I '{}' tsocmd "delete '{}'"

Above command works perfectly.

thinkhy
  • 923
  • 13
  • 25