简体   繁体   English

无法将新文件夹名称附加到UNIX脚本中的现有路径

[英]Not able to append the new folder name to the existing path in UNIX scripting

This is the following code (while loop) in shell scripting 这是shell脚本中的以下代码(while循环)

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) 当我在一开始回显$ {BUP}时,我的输出就是/ psoft / PNRDP1 / sqr /(目录结构)

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 我的任务:尝试将/ ArchFolder附加到上面的输出中,然后再尝试,使用mkdir命令创建目录,如上面的代码片段所示

Some how I see /ArchFolder is not getting concatenating at the end " /psoft/PNRDP1/sqr/ ". 我看到/ ArchFolder的某些方式并没有在结尾“ / psoft / PNRDP1 / sqr / ”串联。

My question is 1) Is there any mistake in concatenation technique. 我的问题是1)串联技术是否有任何错误。

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. 2)或者代替在mkdir中连接并使用该变量,我应在mkdir中附加新的目录名称并执行,该方法是否可以工作,如果可以的话,请告诉我这段代码。

Thanks in advance 提前致谢

Concatenate two variables in Bash is easy, see an example from here : 在Bash中连接两个变量很容易,请参见此处的示例:

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

But an easier solution, without needing an extra variable would be similar of what you have mentioned in the second question : 但是,不需要额外变量的简单解决方案将类似于您在第二个问题中提到的内容:

    mkdir -p "${BUP}/ArchFolder"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM