如何在UNIX Shell脚本中设置最终文件名

问题描述 投票:0回答:1
inputLandingFullPath="$1"
inputDataFileName="$2"
inputLogFullPath="$3"
inputLoadingPath="$4"
Datalake_Key="$5"
Datalake_Id="$6"
InputScheme=${inputDataFileName:19:2}
echo "$InputScheme"
touch ${inputLoadingPath}\tmp-${InputScheme}.json
cp ${inputLoadingPath}\tmp-${InputScheme}.json ${inputLoadingPath}\${InputScheme}.json

当我使用字符串指定字符串时,串联效果很好,但是当我不指定字符串时,串联效果很好。

这很好,产生文件tmp-YS-json:

touch ${inputLoadingPath}\tmp-${InputScheme}.json

这不起作用:

cp ${inputLoadingPath}\tmp-${InputScheme}.json ${inputLoadingPath}\${InputScheme}.json

输出为:

YS

tmp-YS.json.part5

${InputScheme}.json

并且所需的输出是:

YS.json

参数:

sh /Hadoop_SAN/TU_Prod/TMP/BB_Parse_JSON.sh '/Hadoop_SAN/TU_Prod/TMP/' 'tesco_qhv5_extract-YS-2018.08.15.json' '/Hadoop_SAN/TU_Prod/TMP/' '/Hadoop_SAN/TU_Prod/TMP/' 0 0 
shell unix arguments filenames
1个回答
0
投票

而不是使用反斜杠,而是使用正斜杠指定/代替\

$ {inputLoadingPath} / $ {InputScheme} .json

© www.soinside.com 2019 - 2024. All rights reserved.