我试图将值存储在变量中,并试图将结果回显到文件中。但是,当它添加两个变量并将其回显到文件中时,额外的字符将被添加到输出文件中。这是在码头集装箱里发生的,有人能帮忙吗.
IFS=" "
#while read line
while read c s e
do
echo $c $s $e
first=$(echo "PER_${s}_${e}")
#echo -n $first
second=$(echo "/IPD_${c}")
#echo $second
echo $first$second >> /mnt/resource/step2/messages.txt
done < /mnt/resource/step2/job_control/Categories.txt
Categories.txt包含:
129490 201515 201540
我得到的输出如下:
PER__/IPD_PER_201515_201540/IPD_12949029490
但应该是:
PER_201515_201540/IPD_129490
发布于 2018-04-22 22:41:06
我无法重现这个问题,但是您的代码比需要的要复杂得多。
while IFS=" " read c s e; do
first="PER_${s}_${e}"
second="/IPD_${c}"
echo "$first$second" >> /mnt/resource/step2/messages.txt
done < /mnt/resource/step2/job_control/Categories.txt
https://stackoverflow.com/questions/49971236
复制相似问题