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

    Unanswered: newbie aix shell script subtraction problem

    This is driving me nuts. I am trying to write an AIX script to list files created last month. When I get the command working, i'm going to change the "ls -l" to a "rm" command. The code that subtracts 1 from pdate is giving me an error. How do I either subtract 1 from a field? Or how do I ask for the date in a ccyymm-1 format? What I want the script to give me is 200404 in the pdate field, not 200405. Thanks, any help would be greatly appreciated.

    echo
    . /home/db2inst1/.profile
    pdate= date '+%Y%m'

    pdate= $pdate - 1
    $pdate >> cmsdevprune.rpt
    ls -l /cmsbackt/COMMCMSD.0.cmsdev.NODE0000.CATN0000.${pdate}*.* >> cmsdevprune.rpt

  2. #2
    Join Date
    Dec 2003
    Posts
    56
    Somthing along the lines of:

    Code:
    pdate=`date +%Y%m` 
    
    pdate=`expr $pdate - 1`
    Might help you along the path to a solution...`

  3. #3
    Join Date
    Sep 2003
    Posts
    78
    this command doesn't work. i think the pdate field defaults to alpha and it won't subtract 1 from an alpha field. how do I make pdate a numeric field?

  4. #4
    Join Date
    Dec 2003
    Posts
    56
    I just tried thesde two commands again on m,y AIX 5.2 box in a ksh shell and they do exactly what you want...

    Do an "echo $pdate" after both commands to see what the value of pdate is after each step...maybe that will show what is going wrong in your case...

Posting Permissions

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