如何在变量$File Equals中使用的文件名中包含变量



为什么echo不返回-/lsf10/monitors/lpstat_email_1_vmobius-05122021.txt?它返回-->$FILE

#!/usr/bin/ksh
integer max=3
integer i=1
while [[ $i -lt $max ]]
do
today=`date +%m%d%Y`
FILE = "/lsf10/monitors/lpstat_email_$i_vmobius_$today.txt"
echo "the $FILE"
echo $i
echo "the $FILE"
(( i = i + 1 ))
done

在变量周围使用${…}在字符串文本中进行插值-这会使事情变得更清楚,并有助于解释器。

缩进有助于可读性和可维护性。

试试这个:

#!/usr/bin/ksh
integer max=3
integer i=1 
while (( i < max ))
do
today=`date +%m%d%Y`
FILE="/lsf10/monitors/lpstat_email_${i}_vmobius_${today}.txt"
echo "the $FILE"
echo $i
echo "the $FILE"
(( i ++ ))
done

最新更新