Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    78

    Unanswered: writing shell scripts to delete files concatinate problem

    Hi,

    I have an extremely limited knowledge of shell scripts. Here is what I want to do. I would like to set up a shell script to delete, "RM" command, db2 backups from the backup directory. So far, I've come up with a db2 select statement to get today's date - 2 months in a variable with a yyyymm format. Here's what I want to do:

    pdate variable is equal to 200403 (built from sql script)

    what I want to come up with is a command that looks like:

    rm COMMCMSD.0.cmsdev.NODE000.CATN0000.200403*.*

    I don't care if it's pretty, I could hardcode the command in the shell as:

    rm COMMCMSD.0.cmsdev.NODE000.CATN0000.pdate*.*
    or
    put the entire directory in a variable called $pdatecmd

    rm $pdatecmd

    However, I don't know enough to know how to concatinate literals/variables.

    In OS390, I can build the entire statement in SQL, I can't get this to work in the aix shell command because i'm not sure how to delimeter strings within the sql statement. Any help would be appreciated. Thanks!!

  2. #2
    Join Date
    Dec 2003
    Posts
    56
    rm COMMCMSD.0.cmsdev.NODE000.CATN0000.200403*.*
    rm COMMCMSD.0.cmsdev.NODE000.CATN0000.${pdate}*.*

    ${pdate} will put the value of pdate variable into your rm command....

  3. #3
    Join Date
    Sep 2003
    Posts
    78
    your code worked to concatinate my variable into the statement. however, my db2 code to put the value into the statement didn't work. Is there a way to get the system date (minus 1 month) into a variable in a ccyymm format?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •