Problem with a Shell Script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sitko
    New Member
    • Sep 2007
    • 140

    Problem with a Shell Script

    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.

    Code:
    # Creates the date
    DIR_EXT=`date '+%Y%m%d_%H%M%S'`
    
    # 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.
    UNIQUE_DIR=$DIR_EXT_$JOB_NAME
    #This should tie it all together
    JOBDIR=$HOMEDIR/$DIR_STRING/$UNIQUE_DIR
    
    echo "Date string is: $DIR_EXT"
    echo "Unique Directory is: $UNIQUE_DIR"
    echo "Job Directory is: $JOBDIR"
    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.
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by sitko
    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.

    Code:
    # Creates the date
    DIR_EXT=`date '+%Y%m%d_%H%M%S'`
    
    # 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.
    UNIQUE_DIR=$DIR_EXT_$JOB_NAME
    #This should tie it all together
    JOBDIR=$HOMEDIR/$DIR_STRING/$UNIQUE_DIR
    
    echo "Date string is: $DIR_EXT"
    echo "Unique Directory is: $UNIQUE_DIR"
    echo "Job Directory is: $JOBDIR"
    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:

    Code:
    UNIQUE_DIR=${DIR_EXT}_${JOB_NAME}
    Regards,

    Jeff

    Comment

    • kaarthikeyapreyan
      New Member
      • Apr 2007
      • 106

      #3
      Hey try this kid he works

      UNIQUE_DIR=`ech o "$DIR_EXT"_"$JO B_NAME"`

      Comment

      Working...