By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,728 Members | 1,107 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,728 IT Pros & Developers. It's quick & easy.

Problem with a Shell Script

100+
P: 140
Hi,

Its been a long time since I've worked with Shell scripts. I got a script from a co-worker and need it make it do some stuff, and for the life of me, I can get it to work.

Expand|Select|Wrap|Line Numbers
  1. # Creates the date
  2. DIR_EXT=`date '+%Y%m%d_%H%M%S'`
  3.  
  4. # I want this next line to take the date created above and add a "_" and the value in the $JOB_NAME, and make this one directory.
  5. UNIQUE_DIR=$DIR_EXT_$JOB_NAME
  6. #This should tie it all together
  7. JOBDIR=$HOMEDIR/$DIR_STRING/$UNIQUE_DIR
  8.  
  9. echo "Date string is: $DIR_EXT"
  10. echo "Unique Directory is: $UNIQUE_DIR"
  11. echo "Job Directory is: $JOBDIR"
  12.  
Heres the output:

Date string is: 20080313_165404
Unique Directory is: Turner_test11
Job Directory is: /corp/home/ai9542/Reshipper/Turner_test11

My question is why isn't the date string in front of the job name (in this case Turner_test11)?
I want it to be "/corp/home/ai9542/Reshipper/20080313_165404_Turner_test11"

Thanks,
Sitko.
Mar 14 '08 #1
Share this Question
Share on Google+
2 Replies

numberwhun
Expert Mod 2.5K+
P: 3,503
Hi,

Its been a long time since I've worked with Shell scripts. I got a script from a co-worker and need it make it do some stuff, and for the life of me, I can get it to work.

Expand|Select|Wrap|Line Numbers
  1. # Creates the date
  2. DIR_EXT=`date '+%Y%m%d_%H%M%S'`
  3.  
  4. # I want this next line to take the date created above and add a "_" and the value in the $JOB_NAME, and make this one directory.
  5. UNIQUE_DIR=$DIR_EXT_$JOB_NAME
  6. #This should tie it all together
  7. JOBDIR=$HOMEDIR/$DIR_STRING/$UNIQUE_DIR
  8.  
  9. echo "Date string is: $DIR_EXT"
  10. echo "Unique Directory is: $UNIQUE_DIR"
  11. echo "Job Directory is: $JOBDIR"
  12.  
Heres the output:

Date string is: 20080313_165404
Unique Directory is: Turner_test11
Job Directory is: /corp/home/ai9542/Reshipper/Turner_test11

My question is why isn't the date string in front of the job name (in this case Turner_test11)?
I want it to be "/corp/home/ai9542/Reshipper/20080313_165404_Turner_test11"

Thanks,
Sitko.
Not sure, but try defining the variable like this and see if it works:

Expand|Select|Wrap|Line Numbers
  1. UNIQUE_DIR=${DIR_EXT}_${JOB_NAME}
  2.  
Regards,

Jeff
Mar 14 '08 #2

kaarthikeyapreyan
100+
P: 107
Hey try this kid he works

UNIQUE_DIR=`echo "$DIR_EXT"_"$JOB_NAME"`
Mar 18 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.