- eval:
語法:
[test @test test]# eval variable 例題: [test @test test]# days=365 [test @test test]# year=days [test @test test]# echo \$$year $days <==第一個 $ 被 \ 改變成為一般字元,而 \$ 後面接的 $year 就成為 days 啦! [test @test test]# eval echo \$$year 365 加上 eval 之後, \$$year 變成的 $days 的『變數內容』會顯現出來喔! |
1. ~$ name=yawu
~$ echo $name
~$ yawu
2. ~$ yawu=vmd
~$ echo $name
~$ yawu
~$ eval echo \$$name
~$ vmd
3. ~$ eval echo "$""$name"
~$ vmd
or
~$ eval echo '${'"$name"'}'
~$ vmd
链接:https://www.jianshu.com/p/284ae3a0244e
-------------------------------------------------------------------------------------------------------------------------
for ((i=0; i < 2; i++)); do
for ((j=0; j < 3; j++)); do
# ii=$(($i+1))
# eval SAENameAx=\${SAENameA${ii}[j]}
eval SAENameAx=\${SAENameA$(($i+1))[j]}
echo "SAENameAx="$SAENameAx
PathFileName=$(echo $Path/${SAESide[i]}/${SAEDir[j]}/${SAENameAx}"-"$SearchDATE"-task.txt")
echo "PathFileName= "$PathFileName
The_number_of_lines_in_a_file=$(cat $PathFileName |grep -n 'HKT 2019'| wc -l)
echo "The number of lines in a file="$The_number_of_lines_in_a_file
cat ${PathFileName} |grep -n 'HKT 2019' > $Path/tempA_${i}_${j}.txt
for ((k=1; k < $The_number_of_lines_in_a_file; k++)); do
Paragraph_begin=$(cat $Path/tempA_${i}_${j}.txt | sed -n "${k}p" | awk 'BEGIN {FS=":"}; END{print $1}')
Paragraph_begin=$(($Paragraph_begin+5))
k=$(($k+1))
Paragraph_end=$(cat $Path/tempA_${i}_${j}.txt | sed -n "${k}p" | awk 'BEGIN {FS=":"}; END{print $1}')
Paragraph_end=$(($Paragraph_end-2))
cat ${PathFileName} |sed -n "${Paragraph_begin},${Paragraph_end}p" > $Path/tempB_${i}_${j}.txt
done
done
done
沒有留言:
張貼留言