在主函数中,我调用了2个参数并将其传递给函数cleanexpiredfiles,函数cleanexpiredfiles向参数2添加了更多字符,然后传递给函数deleteFiles,现在的问题是:在函数deleteFiles中,$ 2返回正确的结果,但是如果我使用deleteFolder = $ 2,然后$ deleteFolder不返回任何内容,
echo $ 2返回正确的结果 echo $ deleteFolder不返回任何内容
function deleteFiles
{
expireTime=$1
deleteFolder=$2
echo $deleteFolder
}
function cleanexpiredfiles
{
for fileelement in `ls $2`
do
deleteFiles $1 $2"/"$fileelement
done
}
function main()
{
cleanexpiredfiles $((16*60*60)) /opt/gdsmigration/logs
}
main $@
echo $ 2或echo $ deleteFiles应该返回相同的结果,