我一生都无法理解为什么我无法在 while 循环之外阅读 postPrioity。我试过“export postPrioity="500"”还是不行。
有任何想法吗?
-- 或在计划文本中 --
#!/bin/bash
cat "/files.txt" | while read namesInFile; do
postPrioity="500"
#This one shows the "$postPrioity" varible, as '500'
echo "weeeeeeeeee ---> $postPrioity <--- 1"
done
#This one comes up with "" as the $postPrioity varible. GRRR
echo "weeeeeeeeee ---> $postPrioity <--- 2"
输出:(我在 files.txt 中只有 3 个文件名)
weeeeeeeeee ---> 500 <--- 1
weeeeeeeeee ---> 500 <--- 1
weeeeeeeeee ---> 500 <--- 1
weeeeeeeeee ---> <--- 2