UNIX shell将文件从一个文件夹移动到另一个文件夹

时间:2016-12-27 03:15:48

标签: shell unix

  #!/bin/bash

export folder=`date -d "today - 1 days" '+%Y%m%d'`;

if filename in /r1/test/med_sms/FDA3A; then

result=

if filename = *$folder*; then

result= mv $filename /r1/test/med_sms/FDA3A/test

else

if filename = *$folder*; then

result= mv $filename /r1/test/med_sms/FDA3A/test

elif

done;

嗨..我正在尝试执行上面的scrpot,但它将异常抛出为./test1.sh:line 11:语法错误接近意外令牌`done'

./test1.sh: line 11: `done'

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:1)

if

Bash fi语句以Value

结尾

答案 1 :(得分:1)

你不应该以这种方式使用ìf elif语句,根据你的程序结构,这应该是这样的:

export folder=`date -d "today - 1 days" '+%Y%m%d'`;
if filename in /r1/test/med_sms/FDA3A; then
    result= something_here
elif filename = *$folder*; then

    result= mv $filename /r1/test/med_sms/FDA3A/test

elif filename = *$folder*; then
    result= mv $filename /r1/test/med_sms/FDA3A/test

else
    result = PUT here the last condition

fi