0

This is the following code (while loop) in shell scripting

do
    echo "directory under is @ " ${dir} >>${DEBUG_LOG_FILE}
    BUP="$PS_HOME/${PSFT_SID}/${dir}";
    echo "backup folder created is1  :  ${BUP} " ${BUP}   >>${DEBUG_LOG_FILE}
    $BUP=${BUP}+"/ArchFolder"
    BUP1=${BUP}+"ArchFolder" (Since "/" is already in the BUP variable"
    echo "backup folder created is 2 :  ${BUP1} " ${BUP1}   >>${DEBUG_LOG_FILE}
        echo "backup folder created is 3 :  ${BUP} " ${BUP}   >>${DEBUG_LOG_FILE}
    mkdir -p ${BUP}

done

when I echo ${BUP} at the beginning I am getting as /psoft/PNRDP1/sqr/ as the output (directory structure)

My task : Trying to append /ArchFolder to the above output and later, trying to a create a Directory using the mkdir command as you see in the above code snippet

Some how I see /ArchFolder is not getting concatenating at the end "/psoft/PNRDP1/sqr/".

My question is 1) Is there any mistake in concatenation technique.

2) Or instead of concatenate and use that variable in mkdir, shall i append the new Directory name in the mkdir and execute, will that work, if yes can any one show me the piece of code.

Thanks in advance

4

1 に答える 1

1

Bash で 2 つの変数を連結するのは簡単です。こちらの例を参照してください。

foo="Hello"
foo="$foo World"
echo $foo
> Hello World

しかし、追加の変数を必要としないより簡単な解決策は、2 番目の質問で述べたものと似ています。

    mkdir -p "${BUP}/ArchFolder"
于 2013-02-22T11:55:17.387 に答える