-1

I have a text file as below:

[Global]

$DBConnection_prd_load=GETDB

$$SURVEY_TYPE=ALL

$$VENDOR_SURVEY_ID=5

[email protected]

$$LASTRUNDATE=10/24/2013

I want to pass above file $$LASTRUNDATE value to below script. Pl help. And also replace / with _.

#! /bin/ksh

export SRCDIR=/informat/PowerCenter/9.1.0/server

export TGTDIR=/informat/PowerCenter/9.1.0/server/infa

export FILEDT=**$$LASTRUNDATE**

cd ${SRCDIR}

export GET_FNAME=AllResponses_${FILE_NUM}_${FILEDT}*.txt

        if [ -f ${GET_FNAME} ]; then

                cp ${SRCDIR}/${GET_FNAME} ${TGTDIR}

Can you pl also let me know how to replace '\' with '_' ?

Friend..one more small favour..is it possible to add 1 day to date that we get in the above variable..?

3
  • stackoverflow.com/q/2652753/1007273 Commented Oct 25, 2013 at 8:01
  • Sorry dude...its not nonacceptance...its caution..Thanks a lot letting me know the solution... Commented Oct 25, 2013 at 8:13
  • can you please also let me know how to add 1 day to the variable, got date value in the above script. Pl help Commented Oct 25, 2013 at 8:21

2 Answers 2

1

You could just use backticks.

This would produce the output:

cat mytextfile | grep '\$\$LASTRUNDATE=' | sed 's/\$\$LASTRUNDATE=//g'| sed 's/\//_/g'

And this would allow me to store it:

export FILEDT=`cat mytextfile | grep '\$\$LASTRUNDATE=' | sed 's/\$\$LASTRUNDATE=//g' | sed 's/\//_/g'`
Sign up to request clarification or add additional context in comments.

Comments

1

This will give you value in required format :

grep '$$LASTRUNDATE' <file-name> | cut -d= -f2 | sed -e 's/\//\-/g'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.