If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > writing shell scripts to delete files concatinate problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-05-04, 14:35
chinatrain99 chinatrain99 is offline
Registered User
 
Join Date: Sep 2003
Posts: 73
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!!
Reply With Quote
  #2 (permalink)  
Old 05-06-04, 07:58
TimoV TimoV is offline
Registered User
 
Join Date: Dec 2003
Posts: 56
Quote:
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....
Reply With Quote
  #3 (permalink)  
Old 05-06-04, 10:09
chinatrain99 chinatrain99 is offline
Registered User
 
Join Date: Sep 2003
Posts: 73
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?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On