mv命令在shell脚本中不起作用没有此文件

时间:2019-01-30 14:44:25

标签: shell sh

我正在使用sh脚本尝试更新源代码管理中的字段。但是,当我运行命令时,我得到了错误消息:

 mv: cannot stat 'tmp': No such file or directory

我创建了一个tmp文件,应该使用issueNumber填充该文件,然后用yes替换指定的字段。

这是我目前的代码:

issueNum=$1
field=$2
newValue=$3
typeset -A fidMap
# fidMap['type']=7
#fidMap['customerName']=63
#fidMap['patchNum']=58
#fidMap['releaseImplmntdIn']=42
fidMap['state']=5
#fidMap['subsystem']=13
#fidMap['changeRequestNumber']=36
#fidMap['releaseFoundIn']=39
#fidMap['System']=35
#fidMap['assignedTo']=14
if [ "$1" = "" ] || [ "$2" = "" ] || [ "$3" = "" ]; then 
    echo "Please pass in three variables: issueNumber field value"
    echo "Example: new_mod_value.sh 10003 state Approved"
    return 0
fi
echo "issue number $issueNum"
echo "field is $2"
echo "value is $3"
rm runIssue.xml
echo "<queryIssue issueDB=\"TEOCO\" expandUsers=\"true\">" > runIssue.xml
echo "1 == $issueNum" >> runIssue.xml
echo "</queryIssue>" >>runIssue.xml

 accurev xml -l runIssue.xml > issuesOutputtmp.xml
 currentFile=issuesOutputtmp.xml
sed 's/<issues>/<modifyIssue issueDB="TEOCO">/' $currentFile > tmp && mv  tmp $currentFile  
sed 's/<\/issues>/<\/modifyIssue>/' $currentFile > tmp && mv tmp $currentFile
sed 's/fid="2">[0-9]*<\/transNum>/fid="2"><\/transNum>/' $currentFile > tmp && mv tmp $currentFile
grep "<$field" $currentFile >/dev/null
if [ $? -eq 0 ]; then
 SED_ARG=" 's/fid=\"${fidMap[$field]}\">.*/fid=\"${fidMap[$field]}\">$newValue<\/$field>/' $currentFile"
 eval sed $SED_ARG > tmp && mv tmp $currentFile
else
  SED_ARG=" 's/<\/issue>/<$field\
    fid=\"${fidMap[$field]}\">$newValue<\/$field>\
 <\/issue>/' $currentFile"
  eval sed $SED_ARG > tmp && mv tmp $currentFile
fi
#Escaping and cleanup
mv tmp $currentFile
sed 's/&/,/g' $currentFile > tmp && mv tmp $currentFile
#sed 's/</&lt;/g'$currentFile > tmp && mv tmp $currentFile
#sed 's/>/&gt;/g' $currentFile > tmp && mv tmp $currentFile
#sed 's/"/&quot;/g' $currentFile > tmp && mv tmp $currentFile
#sed 's/[^!-~\s]//g' $currentFile > tmp && mv tmp $currentFile
 accurev xml -l $currentFile

任何帮助将不胜感激!谢谢

1 个答案:

答案 0 :(得分:1)

您在许多地方创建了文件;with cte as (select Row_number() over (partition BY id_gen, perpro,valido order by ini desc) RN from tstSolap) delete from cte --update cte set valido = 0 where RN > 1 ,然后直接将其重命名为其他名称。这意味着当您寂寞时将不存在名为tmp的文件

tmp