I figured this out myself.  Something really stupid.  I wasn't putting '{}' at the end of the tar command.  Jeez.

On 5/21/2020 8:47 AM, Michael Babcock wrote:
I have Rocket’s bash, git, findutils, xargs, vim, etc installed on my z/OS 2.4 system and can't seem to make something work.

I have a directory /u/xx35/test that contains directories with names like 20200512, 20200513, 20200514, etc (year, month, day). These directories have other directories and files under them.  I want to tar (but not feather!) each directory over 3 days old.  I only want to archive the directories (which should get everything in that directory and below).

So after archiving it should look like the following (as long as each directory is over 3 days old):

Under /u/xx35/test:

20200512
20200512.tar
20200513
20200513.tar
20200514
20200514.tar

I have a batch job executing the following:

//STEPNAME EXEC PGM=BPXBATSL
//STDPARM  DD DISP=SHR,DSN=XX35.ARCHIVE.FOLDERS
//SYSPRINT DD SYSOUT=*
//SYSIN    DD DUMMY
//STDOUT   DD SYSOUT=*
//STDERR   DD SYSOUT=*

The STDPARM contains:

SH /rsusr/ported/bin/bash -l
/u/xx35/ArchiveDelete.sh /u/xx35/test

ArchiveDelete.sh contains:

#!/rsusr/ported/bin/bash
StartFolder=$1

find $StartFolder -mindepth 1 -maxdepth 1 -type d -mtime +3 | xargs echo

When I run the batch job, it’s output is as it should be no matter which directory I’m in.

IEF375I  JOB/XX35REXX/START 2020140.1451
IEF033I  JOB/XX35REXX/STOP 2020140.1451
CPU:     0 HR  00 MIN  00.00 SEC    SRB:     0 HR  00 MIN 00.00 SEC

/u/xx35/test/20200512 /u/xx35/test/20200513 /u/xx35/test/20200514

But when I change "xargs echo" to "xargs -I '{}' tar -cvzf '{}'.tar" (full command below).

find $StartFolder -mindepth 1 -maxdepth 1 -type d -mtime +3 | xargs -I '{}' tar -cvzf '{}'.tar

It doesn’t execute as I expect it to.  If I do it manually in a VT320 session and am in the /u/xx35/test directory, it works as expected, but if I’m in the directory /u/xx35, it tries to archive everything in that directory and stick it in the /u/xx35/test directory as 20200512.tar.  I’ve looked at numerous examples on the net and mine should work so I don’t understand where I’m going wrong.  I know this is a convoluted way of doing it, but can anyone help?  Need more info?


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to